CreateDefaultCompilerParameters Method

CompilerInfo.CreateDefaultCompilerParameters Method ()


Gets the configured compiler settings for the language provider implementation.

Namespace:   System.CodeDom.Compiler
Assembly:  System (in System.dll)

public CompilerParameters CreateDefaultCompilerParameters()

Return Value

Type: System.CodeDom.Compiler.CompilerParameters

A read-only CompilerParameters instance that contains the compiler options and settings configured for the language provider.

Use the CreateDefaultCompilerParameters method to examine the compiler settings of the CompilerInfo instances returned by the CodeDomProvider.GetAllCompilerInfo and CodeDomProvider.GetCompilerInfo methods.

The <system.codedom> Element in the machine configuration file contains the language provider and compiler configuration settings for each CodeDomProvider implementation on the computer. Each language provider configuration element can contain optional compilerOptions and warningLevel attributes. These attributes define the default values for the CompilerParameters.CompilerOptions and CompilerParameters.WarningLevel properties.

If the language provider configuration element does not define the compilerOptions attribute, the CompilerParameters.CompilerOptions property value is an empty string (""). If the language provider configuration element does not define the warningLevel attribute, the CompilerParameters.WarningLevel property value is –1.

The following code example determines whether the input language has a configured CodeDomProvider implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the CompilerInfo class.

CompilerInfo info = CodeDomProvider.GetCompilerInfo(configLanguage);

// Check whether there is a provider configured for this language.
if (info.IsCodeDomProviderTypeValid)
    // Get a provider instance using the configured type information.
    CodeDomProvider provider;
    provider = (CodeDomProvider)Activator.CreateInstance(info.CodeDomProviderType);

    // Display information about this language provider.
    Console.WriteLine("Language provider:  {0}", 
    Console.WriteLine("  Default file extension:  {0}", 

    // Get the compiler settings for this language.

    CompilerParameters langCompilerConfig = info.CreateDefaultCompilerParameters();

    Console.WriteLine("  Compiler options:        {0}", 
    Console.WriteLine("  Compiler warning level:  {0}", 
    // Tell the user that the language provider was not found.
    Console.WriteLine("There is no provider configured for input language \"{0}\".", 


for calling members of CompilerInfo. Demand value: LinkDemand; Associated PermissionState enumeration value: Unrestricted; NIB: Named Permission Sets: FullTrust.

.NET Framework
Available since 2.0
Return to top
© 2015 Microsoft