views:

105

answers:

3

Me stupid.

How can I know which assembly to reference if I just know the name of the class, for example System.Collections.Specialized.StringCollection.

(Yes, I know that more often than not I can make an educated guess by looking at the namespace.)

Thanks

Alex

+4  A: 

You can check in MSDN: The assembly containing the class is mentioned right at the top:

StringCollection Class

Represents a collection of strings.

Namespace: System.Collections.Specialized

Assembly: System (in System.dll)

0xA3
A: 

Usually you can't since most assemblies contain multiple namespaces. Take the example of the System.Core.dll that was added in .net 3.5. It added additional classes to System.Collections.Generic. Some of the original classes lived in the mscorlib.dll One quick way to find out though would be to open up the "Object Browser" tab in VisualStudio, and click the little "Settings" toolbar button, and makes ure "View Containers" is checked.

Micah
+3  A: 

What I usually do is right-click the "StringCollection" in the editor and click "Go To Definition" then a window will pop up with the title "StringCollection [from Metadata]" then I just hover the mouse pointer to the title and a tooltip appears with the location of the assembly where the class comes from.

Arvin Baccay