Click to See Complete Forum and Search --> : Why must I compile with the /r switch?
Xaeryan
April 3rd, 2001, 01:10 PM
If I have a program that uses the System namespace, I do NOT need a reference to the System.dll from the command line, but other namespaces, such as System.Net require this: csc <filename>.cs /r:System.Net.dll
I'm kinda new here. Can someone explain to me why? What is the difference?
Tom Archer
April 3rd, 2001, 01:53 PM
Think of it like specifying libraries to link with in C++. It just happens that System.dll is linked in automatically since you can't do anything without it. However, you don't necessarily need the other DLLs so you have to manually specify that you want them via the /r switch.
Cheers,
Tom Archer - CodeGuru
Inside C# (early 2001)
Teach Yourself Visual InterDev in 24 Hours
vjpriya
April 10th, 2001, 01:26 AM
Assemblies that are available by default do not need to be brought in explicitly during the compilation with the /r compiler switch. But for assemblies that are not available by default need to be a part of the compilation in order t for the classes within the assembly to be available.
The using keyword is just used to provide a alias to anamespace or a class. It actually does not import any metadata or headers. Hence during compilation, to enable the compiler to know where it can find the assembly which contain all the namespaces and classes we have used , we have to refere those assemblies during compilation with the /reference or /r compiler switch. If we fail to reference all the assemblies we have used, the compiler cannot map the classe and namespaces
jasonker
May 5th, 2001, 05:08 PM
OK. This behavior is by design...but is it a good design?
Since we have the namespace in the source code, why do we need to specify the dll name?
What is the benifit of this design?
Tom Archer
May 5th, 2001, 07:22 PM
/r is simply the means of importing a DLL. All languages - including VC++ and VB - require some means of telling the compiler/linker the necessary libraries.
Cheers,
Tom Archer - TheCodeChannel.com
Inside C#
Visual C++.NET Bible
Teach Yourself Visual InterDev in 24 Hours
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.