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

定義新的編譯器選項。 compiler 區段中可以使用任何數目的 compiler 標記。

注意事項注意事項

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

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

屬性和項目

下列各節將說明屬性、子項目和父項目。

屬性

屬性

說明

compilerOptions

選擇性屬性。

列出要在編譯期間傳遞之其他編譯器特定的選項。

extension

選擇性屬性。

提供用於動態程式碼後置 (Code-Behind) 檔案的分號分隔副檔名清單。 例如,".cs"。

language

選擇性屬性。

提供用於動態編譯檔案中的分號分隔語言清單。 例如,"c#;cs;csharp"。

type

必要屬性。

指定逗號分隔類別/組件組合,表示 .NET Framework 類別 (會擴充 CodeDomProvider 類別) 可用來編譯使用指定之語言或副檔名的所有資源。

warningLevel

選擇性屬性。

指定編譯器警告層級。

子項目

無。

父項目

項目

描述

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 項目。

備註

compiler 項目會定義新的編譯器選項。 您可以在 compiler 區段中用任意數量的 compiler 標記。

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

預設組態

由於 compilers 項目已經遭到取代,根據預設,.NET Framework 2.0 版不會設定 compilers 項目。 不過,system.codeDom 區段中還有已定義的預設 compilers 項目。

這個項目不會明確地設定在 Machine.config 檔案或根 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>

範例

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

<configuration>
   <system.web>
      <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>
      </compilation>
   </system.web>
</configuration>

項目資訊

組態區段處理常式

CompilationSection

組態成員

Compilers

Compiler

可設定的位置

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:使用位置設定來設定特定的目錄

HOW TO:鎖定 ASP.NET 組態設定

參考

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

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

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

System.Configuration

System.Web.Configuration

CompilationSection

Compilers

CompilerCollection

概念

ASP.NET 編譯概觀

ASP.NET Web 網頁語法概觀

ASP.NET 組態檔階層架構和繼承

保護 ASP.NET 組態

ASP.NET 組態案例

其他資源

一般組態設定 (ASP.NET)

ASP.NET 組態設定

ASP.NET 網站管理

ASP.NET 組態檔

ASP.NET 組態 API