編譯的 compilers 項目 (ASP.NET 設定結構描述)

指定 ASP.NET 應用程式支援的編譯器。

注意

在 .NET Framework 2.0 版中,已經使用 system.codeDom 區段中的 compilers 項目取代了這個項目。但是,使用 compilation 項目的 compilers 子項目仍然是有效的,而且將會覆寫位於 system.codedom 區段的 compilers 項目。

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

屬性和項目

下列章節會說明屬性、子項目和父項目。

屬性

無。

子項目

子標記

描述

compiler

定義新的編譯器選項。

compiler 區段中可以使用任何數目的 compiler 標記。

父項目

項目

描述

configuration

指定 Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中需要的根項目 (Root Element)。

system.web

指定組態檔中 ASP.NET 組態設定的根項目 (Root Element),並包含會設定 ASP.NET Web 應用程式以及控制這些應用程式之行為的組態項目。

compilation

設定 ASP.NET 用來編譯應用程式的所有編譯設定。

備註

compilers 項目可指定 ASP.NET 應用程式支援的編譯器。

在 .NET Framework 2.0 版中,已經使用 system.codeDom 區段中的 compilers 項目取代了這個項目。 但是,使用 compilation 項目的 compilers 子項目仍然是有效的,而且將會覆寫位於 system.codedom 區段的 compilers 項目。

預設組態

由於 compilers 項目已經遭到取代,根據預設,.NET Framework 2.0 版不會設定 compilers 項目。 不過,system.codeDom 區段中還有已定義的預設 compilers 項目。 下列 compilers 項目不會明確地在 Machine.configuration 檔案或根 Web.config 檔案中設定。 然而,應用程式傳回的是預設組態。

<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>

下列預設 compilers 項目是在 .NET Framework 1.1 版中的 Machine.config 檔案中設定。

<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>

下列預設 compilers 項目是在 .NET Framework 1.0 版中的 Machine.config 檔案中設定。

<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>

範例

下列程式碼範例中,會示範如何設定應用程式的編譯設定。

<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>

項目資訊

組態區段處理常式

CompilationSection

組態成員

Compilers

CompilerCollection

可設定的位置

Machine.config

根層次的 Web.config

應用程式層級的 Web.config

虛擬或實體目錄層級的 Web.config

需求

Microsoft Internet Information Services (IIS) 5.0、5.1 或 6.0 版

.NET Framework 1.0、1.1 或 2.0 版

Microsoft Visual Studio 2003 或 Visual Studio 2005

請參閱

工作

How to: Configure Specific Folders Using Location Settings

How to: Lock ASP.NET Configuration Settings

參考

system.web 項目 (ASP.NET 設定結構描述)

編譯的 assemblies 項目 (ASP.NET 設定結構描述)

編譯的 buildProviders 項目 (ASP.NET 設定結構描述)

編譯的 codeSubDirectories 項目 (ASP.NET 設定結構描述)

編譯的 compilers 項目 (ASP.NET 設定結構描述)

編譯的 expressionBuilders 項目 (ASP.NET 設定結構描述)

configuration 項目 (一般設定結構描述)

System.Configuration

System.Web.Configuration

CompilationSection

Compilers

CompilerCollection

概念

ASP.NET Web Page Syntax Overview

ASP.NET Web Page Code Model

ASP.NET Configuration File Hierarchy

Securing Configuration

Configuration Inheritance

其他資源

一般組態設定 (ASP.NET)

ASP.NET 組態設定

Configuring ASP.NET Applications

ASP.NET Configuration Files

ASP.NET Configuration API