Export (0) Print
Expand All

CodeDomProvider.IsDefinedLanguage Method

Tests whether a language has a CodeDomProvider implementation configured on the computer.

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

[ComVisibleAttribute(false)]
public static bool IsDefinedLanguage(
	string language
)

Parameters

language
Type: System.String

The language name.

Return Value

Type: System.Boolean
true if a CodeDomProvider implementation is configured for the specified language; otherwise, false.

ExceptionCondition
ArgumentNullException

The language is null.

SecurityException

The caller does not have the required permission.

The <system.codedom> Element in the machine configuration file (Machine.config) contains the language provider and compiler configuration settings for each CodeDomProvider implementation on the computer. The IsDefinedLanguage method searches the provider configuration elements for the specified language name.

Language names are case-insensitive.

The following code example determines the CodeDomProvider implementation for an input language and displays the configured settings for the language provider. This code example is part of a larger example provided for the CompilerInfo class.

CodeDomProvider provider;

// Check for a provider corresponding to the input language.   
if (CodeDomProvider.IsDefinedLanguage(language))
{
    provider = CodeDomProvider.CreateProvider(language);

    // Display information about this language provider.

    Console.WriteLine("Language provider:  {0}", 
        provider.ToString());
    Console.WriteLine();
    Console.WriteLine("  Default file extension:  {0}", 
        provider.FileExtension);
    Console.WriteLine();

    // Get the compiler settings for this language.

    CompilerInfo langCompilerInfo = CodeDomProvider.GetCompilerInfo(language);
    CompilerParameters langCompilerConfig = langCompilerInfo.CreateDefaultCompilerParameters();

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

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

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)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft