More than a year ago, in early Beta1 days of .Net framework, I wrote a very
elementary article on How
to write a Windows Forms application using C#. At that time there was
no version of Visual Studio .Net available. So that article explained how the
application can be written using without IDE.
Now most of us have access to IDE. But it is always nice to have an alternate
way of comiling the application. So I decided to update the old code because a
lot of stuff changed between the early Beta1 and final release of .Net
framework. Also some compiler options changed. So this artcile is simply an
update to that article and code has been updated for .Net Release 1 (SP1).
Some changes in referencing system assemblies during compilation
The application needs to refer to some system assemblies like System.DLL,
System.Windows.Forms.DLL, etc. Earlier we had to specify all these
assembly references through /reference switch. But now C#
compiler looks for CSC.rsp response file in the project directory.
If the response file is not found in the project directory, then it looks for
the file in the directory from where compiler was invoked. Since we are
assuming that you don't have IDE installed, then this compiler will be invoked
from "Windows Folder"\Microsoft.NET\"CLR Version" directory. You
will find a CSC.rsp file there. Take a look at this file. You will
see that it already has added reference to most commonly referenced assemblies.
Therefore you don't need to specify them through /reference switch
anymore.
If you want compiler to ignore the inclusion of default CSC.rsp file,
use /noconfig compilation switch. If you include your own CSC.rsp
file in the project folder, then its settings override the settings specified
in global CSC.rsp file. For more details, please look in the
documentation for this compiler switch. Unfortunately
you cannot specify noconfig switch in Visual Studio .Net IDE.
Other changes
There are namespace changes, attribute name and value changes and some method
name changes in the new code from the previous version that was written for
Beta1. Other than that I did not have to make a whole lot of changes.
What Next?
Next we will try to write an article that will show how an ASP.Net application
can be written without the help of IDE. and it will show how ASP.Net references
the assemblies at compile time and run time.