Section E.1. Compiler Basics

   

E.1 Compiler Basics

Syntactically, the compiler is fairly typical in that it uses command-line switches to control its operation. A command-line switch is designated by a slash or hyphen followed by a keyword. If the keyword takes an argument, it is separated from the keyword by a colon (:). For example:

 vbc sample1.vb /target:library 

supplies the library keyword as an argument to create a library file (that is, a DLL). If multiple arguments are required, they are separated from one another by commas. For example:

 vbc sample1.vb /r:system.design.dll,system.messaging.dll 

references the metadata in the system.design.dll and system.messaging.dll assemblies.

The minimal syntax required to compile a file named sample1.vb is:

 vbc sample1.vb 

This generates a console-mode application. You can specify the type of component or application you wish to generate by using the /target switch. To generate a Windows executable, you'd enter something like the following at the command line:

 vbc sample1.vb /t:winexe /r:system.windows.forms.dll 

Note the /r switch, which adds a reference to the assembly that contains the system.windows.forms namespace. You must explicitly add references to any assemblies your application requires, other than mscorlib.dll and microsoft.visualbasic.dll .

To compile multiple files, just list them on the command line using a space to separate them. For example:

 vbc sample1.vb sample2.vb /t:winexe /r:system.windows.forms.dll 

Since sample1.vb is the first file we listed and we haven't explicitly designated an output filename, the compiler will generate a Windows executable named sample1.exe .

   


VB.Net Language in a Nutshell
VB.NET Language in a Nutshell
ISBN: B00006L54Q
EAN: N/A
Year: 2002
Pages: 503

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net