次の方法で共有


compilers Element for compilation (ASP.NET Settings Schema) 

Specifies the compilers that the ASP.NET application supports.

NoteNote

In the .NET Framework version 2.0, this element is deprecated in favor of the compilers element of the system.codeDom section. However, using the compilers child element of the compilation element is still valid and overrides the compilers element that is located in the system.codedom section.

<compilers> 
   <compiler language="language"
             extension="ext"
             type=".NET Type" 
             warningLevel="number"  
             compilerOptions="options"/>
</compilers>

Attributes and Elements

The following sections describe attributes, child elements, and parent elements.

Attributes

None.

Child Elements

Subtag Description

compiler

Defines a new compiler option.

Any number of compiler tags can be used in the compiler section.

Parent Elements

Element Description

configuration

Specifies the required root element in every configuration file that is used by the common language runtime and the .NET Framework applications.

system.web

Specifies the root element for the ASP.NET configuration settings in a configuration file and contains configuration elements that configure ASP.NET Web applications and control how the applications behave.

compilation

Configures all compilation settings that ASP.NET uses to compile applications.

Remarks

The compilers element specifies the compilers that the ASP.NET application supports.

In the .NET Framework version 2.0, this element is deprecated in favor of the compilers element of the system.codeDom section. However, using the compilers child element of the compilation element is still valid and overrides the compilers element that is located in the system.codedom section.

Default Configuration

By default, the compilers element is not configured in the .NET Framework version 2.0 because the compilers element has been deprecated. However, there is a default compilers element that is defined in the system.codeDom section. The compilers element is not explicitly configured in the Machine.configuration file or in the root Web.config file. However, it is the default configuration that is returned by the application.

<system.codedom>
   <compilers>
       <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%ECMA_PUBLICKEY%" warningLevel="1" />
       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%ECMA_PUBLICKEY%" />
       <compiler language="js;jscript;javascript" extension=".js" type="Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=8.0.1100.0, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%" />
       <compiler language="vj#;vjs;vjsharp" extension=".jsl" type="Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%" />
       <compiler language="c++;mc;cpp" extension=".h" type="Microsoft.VisualC.CppCodeProvider, CppCodeProvider, Version=8.0.0.0, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%" />
   </compilers>
</system.codedom>

The following default compilers element is configured in the Machine.config file for the .NET Framework version 1.1.

<compilers>
   <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="1"/>
   <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
   <compiler language="js;jscript;javascript" extension=".js" type="Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
   <compiler language="VJ#;VJS;VJSharp" extension=".jsl" type="Microsoft.VJSharp.VJSharpCodeProvider, VJSharpCodeProvider, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</compilers>

The following default compilers element is configured in the Machine.config file for the .NET Framework version 1.0.

<compilers>
    <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="1" />
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <compiler language="js;jscript;javascript" extension=".js" type="Microsoft.JScript.JScriptCodeProvider, Microsoft.JScript, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</compilers>

Example

The following code example demonstrates how to configure compilation settings for an application.

<compilation defaultLanguage="VB"
    debug="true"
    numRecompilesBeforeAppRestart="15">
    
    <compilers>
       <compiler language="VB;VBScript"
          extension=".cls"
          type="Microsoft.VisualBasic.VBCodeProvider,system,     
           Version=1.0.5000.0, Culture=neutral, 
           PublicKeyToken=b77a5c561934e089"/>
       <compiler language="C#;Csharp"
          extension=".cs" 
          type="Microsoft.CSharp.CSharpCodeProvider,system, 
           Version=1.0.5000.0,  Culture=neutral, 
           PublicKeyToken=b77a5c561934e089"/>
    </compilers>

    <assemblies>
       <add assembly="ADODB"/>
       <add assembly="*"/>
    </assemblies>

      </compilation>

Element Information

Configuration section handler

CompilationSection

Configuration member

Compilers

CompilerCollection

Configurable locations

Machine.config

Root-level Web.config

Application-level Web.config

Virtual or physical directory–level Web.config

Requirements

Microsoft Internet Information Services (IIS) version 5.0, 5.1, or 6.0

The .NET Framework version 1.0, 1.1, or 2.0

Microsoft Visual Studio 2003 or Visual Studio 2005

See Also

Tasks

How to: Configure Specific Directories Using Location Settings
How to: Lock ASP.NET Configuration Settings

Reference

system.web Element (ASP.NET Settings Schema)
assemblies Element for compilation (ASP.NET Settings Schema)
buildProviders Element for compilation (ASP.NET Settings Schema)
codeSubDirectories Element for compilation (ASP.NET Settings Schema)
compilers Element for compilation (ASP.NET Settings Schema)
expressionBuilders Element for compilation (ASP.NET Settings Schema)
configuration Element (General Settings Schema)
System.Configuration
System.Web.Configuration
CompilationSection
Compilers
CompilerCollection

Concepts

ASP.NET Compilation Model
ASP.NET Web Page Code Model
ASP.NET Web Site Precompilation Overview
ASP.NET Configuration File Hierarchy and Inheritance
Securing ASP.NET Configuration
ASP.NET Configuration Scenarios

Other Resources

General Configuration Settings (ASP.NET)
ASP.NET Configuration Settings
Configuring ASP.NET Applications
ASP.NET Configuration Files
ASP.NET Configuration API