I created a new VS “empty” project, and in it made a class. I decided to try this out as a library, went into properties and set the output type to class library. It compiles to a dll, though when I add it as a reference to another project, typing in “using …” doesn’t have my new library in there. If I create a new library project, past my class in there, compile that into a dll, then it works fine. So what I want to know is, what settings to I need to change in a blank project to get it to act as a dll?
Share
usingdirectives are about namespaces, not assemblies.If your library is empty, it’s not contributing anything to a namespace, so a using directive won’t find anything.
It’s very important that you understand the difference between a namespace and an assembly – you could have library
Foo.dllwhich only containsBar.Xyz. You would add a reference in your project toFoo.dll, but a using directive forBar.As a more concrete example, the
Enumerableclass in theSystem.Linqnamespace comes fromSystem.Core.dll– but you still add theusingdirective forSystem.Linq, notSystem.Core. Indeed, if you try to add ausingdirective forSystem.Core, you’ll get an error – because that namespace doesn’t exist. (A namespace effectively doesn’t exist if it has no members.)