richzilla
richzilla

Reputation: 42002

Why don't I need references for a non visual studio c# application

When developing a C# applications in Visual Studio, I need to add a reference to the library I want to make use of before I can import it into the application with the using keyword.

If I don't use Visual Studio, I can import libraries without having to add a reference to them first. Really my question has two points:

Upvotes: 4

Views: 114

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1500615

If you look in the same directory as csc.exe, you'll find a file called csc.rsp. That lists all the references which are effectively automatically added. The C# compiler still needs to know what to look for - but it has a great big default list.

If you use the /noconfig flag then you'll see the same behaviour as with Visual Studio - every reference has to be listed explicitly.

As for what adding a reference does to a project: it tells the C# compiler to use that library. That's all. Note that using directives are to do with namespaces, not assemblies. They're often named the same, but they're completely separate concepts. A using directive does not "import" a library - it just instructs the C# compiler to look for members within that namespace when resolving names.

Upvotes: 6

Related Questions