System.CodeDom.Compiler.CompilerParameters Class

Represents the parameters used to invoke a compiler.

See Also: CompilerParameters Members

Syntax

public class CompilerParameters

Remarks

A System.CodeDom.Compiler.CompilerParameters object represents the settings and options for an System.CodeDom.Compiler.ICodeCompiler interface.

If you are compiling an executable program, you must set the CompilerParameters.GenerateExecutable property to true. When the CompilerParameters.GenerateExecutable is set to false, the compiler will generate a class library. By default, a new System.CodeDom.Compiler.CompilerParameters is initialized with its CompilerParameters.GenerateExecutable property set to false. If you are compiling an executable from a CodeDOM graph, a System.CodeDom.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 CompilerParameters.MainClass property.

You can specify a file name for the output assembly in the CompilerParameters.OutputAssembly property. Otherwise, a default output file name will be used. To include debug information in a generated assembly, set the CompilerParameters.IncludeDebugInformation property to true. If your project references any assemblies, you must specify the assembly names as items in a System.Collections.Specialized.StringCollection set to the CompilerParameters.ReferencedAssemblies property of the System.CodeDom.Compiler.CompilerParameters used when invoking compilation.

You can compile an assembly that is written to memory rather than disk by setting the CompilerParameters.GenerateInMemory property to true. When an assembly is generated in memory, your code can obtain a reference to the generated assembly from the CompilerResults.CompiledAssembly property of a System.CodeDom.Compiler.CompilerResults. If an assembly is written to disk, you can obtain the path to the generated assembly from the CompilerResults.PathToAssembly property of a System.CodeDom.Compiler.CompilerResults.

To specify a warning level at which to halt compilation, set the CompilerParameters.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 CompilerParameters.TreatWarningsAsErrors property to true.

To specify a custom command-line arguments string to use when invoking the compilation process, set the string in the CompilerParameters.CompilerOptions property. If a Win32 security token is required to invoke the compiler process, specify the token in the CompilerParameters.UserToken property. To include .NET Framework resource files in the compiled assembly, add the names of the resource files to the CompilerParameters.EmbeddedResources property. To reference .NET Framework resources in another assembly, add the names of the resource files to the CompilerParameters.LinkedResources property. To include a Win32 resource file in the compiled assembly, specify the name of the Win32 resource file in the CompilerParameters.Win32Resource property.

Note:

This class contains a link demand and an inheritance demand at the class level that applies to all members. A System.Security.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.

Requirements

Namespace: System.CodeDom.Compiler
Assembly: System (in System.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0, 4.0.0.0