Represents the parameters used to invoke a compiler.
Assembly: System (in System.dll)
Thetype exposes the following members.
|CompilerParameters()||Initializes a new instance of the class.|
|CompilerParameters(String)||Initializes a new instance of the class using the specified assembly names.|
|CompilerParameters(String, String)||Initializes a new instance of the class using the specified assembly names and output file name.|
|CompilerParameters(String, String, Boolean)||Initializes a new instance of the class using the specified assembly names, output name, and a value indicating whether to include debug information.|
|CompilerOptions||Gets or sets optional command-line arguments to use when invoking the compiler.|
|CoreAssemblyFileName||Gets or sets the name of the core or standard assembly that contains basic types such as Object, String, or Int32.|
|EmbeddedResources||Gets the .NET Framework resource files to include when compiling the assembly output.|
|Evidence||Obsolete. Specifies an evidence object that represents the security policy permissions to grant the compiled assembly.|
|GenerateExecutable||Gets or sets a value indicating whether to generate an executable.|
|GenerateInMemory||Gets or sets a value indicating whether to generate the output in memory.|
|IncludeDebugInformation||Gets or sets a value indicating whether to include debug information in the compiled executable.|
|LinkedResources||Gets the .NET Framework resource files that are referenced in the current source.|
|MainClass||Gets or sets the name of the main class.|
|OutputAssembly||Gets or sets the name of the output assembly.|
|ReferencedAssemblies||Gets the assemblies referenced by the current project.|
|TempFiles||Gets or sets the collection that contains the temporary files.|
|TreatWarningsAsErrors||Gets or sets a value indicating whether to treat warnings as errors.|
|UserToken||Gets or sets the user token to use when creating the compiler process.|
|WarningLevel||Gets or sets the warning level at which the compiler aborts compilation.|
|Win32Resource||Gets or sets the file name of a Win32 resource file to link into the compiled assembly.|
|Equals(Object)||Determines whether the specified object is equal to the current object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as the default hash function. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a string that represents the current object. (Inherited from Object.)|
A object represents the settings and options for an ICodeCompiler interface.
If you are compiling an executable program, you must set the GenerateExecutable property to true. When the GenerateExecutable is set to false, the compiler will generate a class library. By default, a new is initialized with its GenerateExecutable property set to false. If you are compiling an executable from a CodeDOM graph, a CodeEntryPointMethod must be defined in the graph. If there are multiple code entry points, you can indicate the class that defines the entry point to use by setting the name of the class to the MainClass property.
You can specify a file name for the output assembly in the OutputAssembly property. Otherwise, a default output file name will be used. To include debug information in a generated assembly, set the IncludeDebugInformation property to true. If your project references any assemblies, you must specify the assembly names as items in a StringCollection set to the ReferencedAssemblies property of the used when invoking compilation.
You can compile an assembly that is written to memory rather than disk by setting the GenerateInMemory property to true. When an assembly is generated in memory, your code can obtain a reference to the generated assembly from the CompiledAssembly property of a CompilerResults. If an assembly is written to disk, you can obtain the path to the generated assembly from the PathToAssembly property of a CompilerResults.
To specify a warning level at which to halt compilation, set the WarningLevel property to an integer that represents the warning level at which to halt compilation. You can also configure the compiler to halt compilation if warnings are encountered by setting the TreatWarningsAsErrors property to true.
To specify a custom command-line arguments string to use when invoking the compilation process, set the string in the CompilerOptions property. If a Win32 security token is required to invoke the compiler process, specify the token in the UserToken property. To include .NET Framework resource files in the compiled assembly, add the names of the resource files to the EmbeddedResources property. To reference .NET Framework resources in another assembly, add the names of the resource files to the LinkedResources property. To include a Win32 resource file in the compiled assembly, specify the name of the Win32 resource file in the Win32Resource property.
This class contains a link demand and an inheritance demand at the class level that applies to all members. A SecurityException is thrown when either the immediate caller or the derived class does not have full-trust permission. For details about security demands, see Link Demands and Inheritance Demands.
The following example builds a CodeDOM source graph for a simple Hello World program. The source is then saved to a file, compiled into an executable, and run. The CompileCode method illustrates how to use the class to specify various compiler settings and options.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)