<assemblyBinding > 元素<运行库 ><assemblyBinding> Element for <runtime>

包含有关程序集版本重定向和程序集位置的信息。Contains information about assembly version redirection and the locations of assemblies.

<configuration><configuration>
<运行时 ><runtime>
<assemblyBinding><assemblyBinding>

语法Syntax

      <assemblyBinding    
   xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">  
</assemblyBinding>  

特性和元素Attributes and Elements

下列各节描述了特性、子元素和父元素。The following sections describe attributes, child elements, and parent elements.

特性Attributes

特性Attribute 描述Description
xmlnsxmlns 必需的特性。Required attribute.

指定程序集绑定所需的 XML 命名空间。Specifies the XML namespace required for assembly binding. 使用字符串“urn: 架构-microsoft-com:asm.v1”作为值。Use the string "urn:schemas-microsoft-com:asm.v1" as the value.
appliesToappliesTo 指定 .NET Framework 程序集重定向适用的运行时版本。Specifies the runtime version the .NET Framework assembly redirection applies to. 此可选特性用 .NET Framework 版本号来指示其适用的版本。This optional attribute uses a .NET Framework version number to indicate what version it applies to. 如果没有指定 appliesTo 特性,<assemblyBinding> 元素将适用于 .NET Framework 的所有版本。If no appliesTo attribute is specified, the <assemblyBinding> element applies to all versions of the .NET Framework. AppliesTo .NET Framework 版本 1.1 中引入了属性;.NET Framework 1.0 版将忽略它。The appliesTo attribute was introduced in .NET Framework version 1.1; it is ignored by the .NET Framework version 1.0. 这意味着,即使指定了 appliesTo 特性,在使用 .NET Framework 1.0 版时所有的 <assemblyBinding> 元素也都适用。This means that all <assemblyBinding> elements are applied when using the .NET Framework version 1.0, even if an appliesTo attribute is specified.

子元素Child Elements

元素Element 描述Description
<dependentAssembly><dependentAssembly> 封装程序集的绑定策略和程序集位置。Encapsulates binding policy and assembly location for an assembly. 使用一个 <dependentAssembly > 标记每个程序集。Use one <dependentAssembly> tag for each assembly.
<probing><probing> 指定加载程序集时公共语言运行时搜索的子目录。Specifies subdirectories the common language runtime searches when loading assemblies.
<publisherPolicy><publisherPolicy> 指定运行时是否使用发布者策略。Specifies whether the runtime applies publisher policy.
<qualifyAssembly><qualifyAssembly> 指定使用部分名称时应动态加载的程序集全名。Specifies the full name of the assembly that should be dynamically loaded when a partial name is used.

父元素Parent Elements

元素Element 描述Description
configuration 公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。The root element in every configuration file used by the common language runtime and .NET Framework applications.
runtime 包含有关程序集绑定和垃圾回收的信息。Contains information about assembly binding and garbage collection.

示例Example

下面的示例显示如何将一个程序集版本重定向到另一个版本并提供基本代码。The following example shows how to redirect one assembly version to another and provide a codebase.

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <dependentAssembly>  
            <assemblyIdentity name="myAssembly"  
                              publicKeyToken="32ab4ba45e0a69a1"  
                              culture="neutral" />  
            <bindingRedirect oldVersion="1.0.0.0"  
                             newVersion="2.0.0.0"/>  
            <codeBase version="2.0.0.0"  
                      href="http://www.litwareinc.com/myAssembly.dll"/>  
         </dependentAssembly>  
      </assemblyBinding>  
   </runtime>  
</configuration>  

下面的示例演示如何使用appliesTo属性重定向.NET Framework 程序集的绑定。The following example shows how to use the appliesTo attribute to redirect binding of a .NET Framework assembly.

<runtime>  
   <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v1.0.3705">  
      <dependentAssembly>   
         <assemblyIdentity name="mscorcfg" publicKeyToken="b03f5f7f11d50a3a" culture=""/>  
         <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="1.0.3300.0"/>  
      </dependentAssembly>  
   </assemblyBinding>  
</runtime>  

请参阅See also