compilation 的 buildProviders 元素(ASP.NET 设置架构)

[本文档仅供预览,在以后的发行版中可能会发生更改。包含的空白主题用作占位符。]

定义用于编译自定义资源文件的生成提供程序的集合。

<buildProviders> 
   <add />
   <clear/>
   <remove />
</buildProviders>

特性和元素

以下几节描述了特性、子元素和父元素。

特性

无。

子元素

子标记

说明

add

可选元素。

向集合添加生成提供程序。

clear

可选元素。

移除对继承的生成提供程序的所有引用,只允许那些由当前 add 元素添加的生成提供程序。

remove

可选元素。

从集合中移除对继承的生成提供程序的引用。

父元素

元素

说明

configuration

指定公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。

system.web

为 ASP.NET 配置节指定根元素。

compilation

配置 ASP.NET 用于编译应用程序的所有编译设置。

备注

buildProviders 元素定义生成提供程序的集合,这些提供程序用于在编译期间编译特定文件类型的自定义资源文件并生成代码。

若要为 ASP.NET 应用程序中的某个文件类型定义自定义生成操作,必须从 BuildProvider 类派生类,在派生类中实现用于生成该文件类型的成员并为应用程序配置文件中相应的文件扩展名配置生成提供程序。 有关信息,请参见BuildProvider

默认配置

下面的默认 buildProviders 元素不是在 Machine.config 文件或根 Web.config 文件中显式配置的, 而是由应用程序返回的默认配置。 项将添加到根 Web.config 文件中的 buildProviders 集合。

<buildProviders>
   <clear />
</buildProviders>

下面的默认 buildProviders 元素是在根 Web.config 文件中配置的。

<buildProviders>
   <add extension=".aspx" type="System.Web.Compilation.PageBuildProvider"/>
   <add extension=".ascx" type="System.Web.Compilation.UserControlBuildProvider"/>
   <add extension=".master" type="System.Web.Compilation.MasterPageBuildProvider"/>
   <add extension=".asix" type="System.Web.Compilation.ImageGeneratorBuildProvider"/>
   <add extension=".asmx" type="System.Web.Compilation.WebServiceBuildProvider"/>
   <add extension=".ashx" type="System.Web.Compilation.WebHandlerBuildProvider"/>
   <add extension=".soap" type="System.Web.Compilation.WebServiceBuildProvider"/>
   <add extension=".resx" type="System.Web.Compilation.ResXBuildProvider"/>
   <add extension=".resources" type="System.Web.Compilation.ResourcesBuildProvider"/>
   <add extension=".wsdl" type="System.Web.Compilation.WsdlBuildProvider"/>
   <add extension=".xsd" type="System.Web.Compilation.XsdBuildProvider"/>
   <add extension=".js" type="System.Web.Compilation.ForceCopyBuildProvider"/>
</buildProviders>

示例

下面的代码示例演示如何定义生成提供程序,该提供程序用于编译具有指定扩展名的自定义资源文件。

<configuration>
   <system.web>
      <compilation>
         <buildProviders>
            <buildProvider 
               extension=".mafx" 
               type="MyBuildProviderType, MyBuildProviderAssembly" />
         </buildProviders>
      </compilation>
   </system.web>
</configuration>

元素信息

配置节处理程序

CompilationSection

配置成员

BuildProviders

BuildProviderCollection

可配置的位置

Machine.config

根级别的 Web.config

应用程序级别的 Web.config

虚拟或物理目录级别的 Web.config

要求

Microsoft Internet 信息服务 (IIS) 5.0、5.1 或 6.0

.NET Framework 2.0

Microsoft Visual Studio 2003 或 Visual Studio 2005

请参见

任务

How to: Configure Specific Folders Using Location Settings

How to: Lock ASP.NET Configuration Settings

参考

compilation 元素(ASP.NET 设置架构)

compilation 的 buildProviders 的 add 元素(ASP.NET 设置架构)

compilation 的 buildProviders 的 clear 元素(ASP.NET 设置架构)

compilation 的 buildProviders 的 remove 元素(ASP.NET 设置架构)

compilation 的 assemblies 元素(ASP.NET 设置架构)

compilation 的 codeSubDirectories 元素(ASP.NET 设置架构)

compilation 的 compilers 元素(ASP.NET 设置架构)

用于编译的 expressionBuilders 元素(ASP.NET 设置架构)

configuration 元素(常规设置架构)

system.web 元素(ASP.NET 设置架构)

System.Configuration

System.Web.Configuration

CompilationSection

BuildProviders

BuildProviderCollection

概念

ASP.NET Compilation Model

ASP.NET Web Page Syntax Overview

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