Search code examples
c#.netvisual-studio.net-assemblyusing

How to know what assembly to add C#


I've ran into this issue a couple times and I'm wondering if anyone has a better solution than trial and error or searching stack overflow.

Lets say we are using some .net class Foo

Foo resides in the Bar.Baz namespace

The following statement

using Bar.Baz;

is not sufficient to compile the program, we are missing an assembly reference. So add a reference to System.Bar.Baz It still doesn't work so after searching the internet I find that I actually have to add a reference to Some.Other.dll and now it compiles.

My question is how do I know what namespace maps to what reference when the usual one doesn't work?

Most recent problem was The type or namespace name 'DbContext' could not be found Instead of adding a reference to System.Data.Entity I had to install through Nuget.


Solution

  • If it is a .NET framework function, you can just search it on MSDN, and it will tell you in which assembly the class/function exists.

    You can also use ReSharper which is a very nice plugin to Visual Studio, and it can help you add assemblies automatically.