定义新的编译器选项。在 compiler 节中可以使用任意数目的 compiler 标记。
![]() |
---|
在 .NET Framework 2.0 版中,此元素已被否决,而改为使用 |
??system.web 元素(ASP.NET 设置架构)
????compilation 元素(ASP.NET 设置架构)
??????compilation 的 compilers 元素(ASP.NET 设置架构)
????????compilation 的 compilers 的 compiler 元素(ASP.NET 设置架构)
<compiler language="language" extension="ext" type=".NET Type" warningLevel="number" compilerOptions="options" /> |
属性和元素
下面几部分描述了属性、子元素和父元素。
属性
属性 | 说明 |
---|---|
compilerOptions |
可选的属性。 列出编译期间要传递的附加编译器特定的选项。 |
extension |
可选的属性。 提供用于动态代码隐藏文件的文件扩展名的分号分隔的列表,如 |
language |
可选的属性。 提供在动态编译文件中使用的语言的分号分隔的列表,如 |
type |
必选的属性。 指定逗号分隔的类/程序集组合,该组合指示用于编译使用指定语言或文件扩展名的所有资源的 .NET Framework 类(此类扩展 |
warningLevel |
可选的属性。 指定编译器警告等级。 |
子元素
无。
父元素
元素 | 说明 | ||
---|---|---|---|
configuration |
指定公共语言运行库和 .NET Framework 应用程序所使用的每个配置文件中均需要的根元素。 |
||
system.web |
指定配置文件中 ASP.NET 配置设置的根元素,并包含用于配置 ASP.NET Web 应用程序和控制应用程序行为方式的配置元素。 |
||
compilation |
配置 ASP.NET 用于编译应用程序的所有编译设置。 |
||
compilers |
指定 ASP.NET 应用程序支持的编译器。
|
备注
compiler 元素定义一个新的编译器选项。您可以在 compiler 节内使用任意数量的 compiler 标记。
在 .NET Framework 2.0 版中,此元素已被否决,而改为使用
默认配置
在 .NET Framework 2.0 版中,默认情况下不配置 compilers 元素,因为 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> |
元素信息
配置节处理程序 |
|
配置成员 |
|
可配置的位置 |
Machine.config 根级别的 Web.config 应用程序级别的 Web.config 虚拟或物理目录级别的 Web.config |
要求 |
Microsoft Internet 信息服务 (IIS) 版本 5.0、5.1 或 6.0 .NET Framework 版本 1.0、1.1 或 2.0 Microsoft Visual Studio 2003 或 Visual Studio 2005 |
请参见
任务
参考
compilation 的 compilers 元素(ASP.NET 设置架构)configuration 元素(常规设置架构)
system.web 元素(ASP.NET 设置架构)
概念
其他资源
常规配置设置 (ASP.NET)ASP.NET 配置设置
