Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio: Find the assembly of a class

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

like image 639
Alex Janzik Avatar asked Jan 13 '09 10:01

Alex Janzik


3 Answers

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.

like image 67
Arvin Baccay Avatar answered Oct 22 '22 03:10

Arvin Baccay


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)

like image 33
Dirk Vollmar Avatar answered Oct 22 '22 02:10

Dirk Vollmar


Tested in VS 2008:

  • in Class View search for the class you need assembly for
  • right click and select "Browse Definition"
  • in the Object Browser window toolbar click on the icon "Add to References in Selected Project in Solution Explorer"

EDIT:

  • Or you can just open the "Object Browser" from the View menu instead of the first two steps and do search for the class directly in the Object Browser window.
  • Does not work all the time. Sometimes the "Add" fails with unspecified error. Happens if the project name in VS does not match the assembly name. In that case you will have to look into that project and figure out where its .dll files are.
like image 30
Korusef Avatar answered Oct 22 '22 01:10

Korusef