Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Given a class in Visual Studio, how to find out which dll contains it?

Working on modifying an existing .NET project. Given a C# class in Visual Studio, how can I find out which DLL has it?

The problem is that I want to use a method in this class in a new project so I need to find the correct DLL to add as a reference for the new project.

like image 640
Jason Avatar asked Sep 03 '15 14:09

Jason


3 Answers

Search for your class name in the object browser (Menu View -> Object Browser). The assembly information window will contain the dll complete path.

like image 157
Spell Avatar answered Nov 19 '22 02:11

Spell


This can be rather frustrating and irritating - I found myself in a situation where I needed an answer to the OP's question and none of the above answers worked for me.

I had a program that imported some Roslyn DLLs. Later, after I'd become unsure as to which DLLs were really necessary, I was trying to find out which classes were in which DLLs.

For example, my program referenced class MSBuildWorkspace. Navigating to the class declaration I can see the namespace name, and the fully qualified name of the class is Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.

Opening the Object Browser, as suggested by @Spell, and searching for Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace results in "Search found no results", which I'm guessing must be due to a bug in Visual Studio.

Fortunately, searching for just MSBuildWorkspace does find the class, but it still didn't tell me which DLL contains the class.

So what I needed to do was to click on the class name, which is shown as a link, in the smallish panel in the lower right part of Object Browser. This results in the left panel switching to a view of the DLLs and the classes they contain. Now I could see that class MSBuildWorkspace was in DLL Microsoft.CodeAnalysis.Workspaces, and right-clicking on that and selecting Copy and pasting the result into a text editor provided the full path to the DLL.

like image 32
RenniePet Avatar answered Nov 19 '22 01:11

RenniePet


You can see the assembly in the project properties. The output name of the DLL (which is what a Class Library project produces) is specified in there.

like image 2
Mathew Grabau Avatar answered Nov 19 '22 02:11

Mathew Grabau