Web design careers - CHAPTER 2 BUILDING C# APPLICATIONS 39 When
CHAPTER 2 BUILDING C# APPLICATIONS 39 When you run the program again, the output is identical. The only difference between the two applications is the fact that the current logic has been split among multiple files. Referencing Multiple External Assemblies On a related note, what if you need to reference numerous external assemblies using csc.exe? Simply list each assembly using a semicolon-delimited list. You don t need to specify multiple external assemblies for the current example, but some sample usage follows: csc /r:System.Windows.Forms.dll;System.Drawing.dll *.cs Working with csc.exe Response Files As you might guess, if you were to build a complex C# application at the command prompt, your life would be full of pain as you type in the flags that specify numerous referenced assemblies and *.cs input files. To help lessen your typing burden, the C# compiler honors the use of response files. C# response files contain all the instructions to be used during the compilation of your current build. By convention, these files end in a *.rsp (response) extension. Assume that you have created a response file named TestApp.rsp that contains the following arguments (as you can see, comments are denoted with the # character): # This is the response file # for the TestApp.exe app # of Chapter 2. # External assembly references. /r:System.Windows.Forms.dll # output and files to compile (using wildcard syntax). /target:exe /out:TestApp.exe *.cs Now, assuming this file is saved in the same directory as the C# source code files to be compiled, you are able to build your entire application as follows (note the use of the @ symbol): csc @TestApp.rsp If the need should arise, you are also able to specify multiple *.rsp files as input (e.g., csc @FirstFile.rsp @SecondFile.rsp @ThirdFile.rsp). If you take this approach, do be aware that the compiler processes the command options as they are encountered! Therefore, command-line arguments in a later *.rsp file can override options in a previous response file. Also note that flags listed explicitly on the command line before a response file will be overridden by the specified *.rsp file. Thus, if you were to enter csc /out:MyCoolApp.exe @TestApp.rsp the name of the assembly would still be TestApp.exe (rather than MyCoolApp.exe), given the /out:TestApp.exe flag listed in the TestApp.rsp response file. However, if you list flags after a response file, the flag will override settings in the response file. Thus, in the following command set, your assembly is indeed named MyCoolApp.exe. csc @TestApp.rsp /out:MyCoolApp.exe Note The /reference flag is cumulative. Regardless of where you specify external assemblies (before, after, or within a response file) the end result is a summation of each reference assembly.
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.