<執行時間的 <assemblyBinding > 元素 ><assemblyBinding> Element for <runtime>

包含有關組件版本重新導向和組件位置的資訊。Contains information about assembly version redirection and the locations of assemblies.

<configuration> <configuration>
    <runtime >   <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:schemas-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. 這表示在使用 .NET Framework 1.0 版時,會套用所有 <assemblyBinding> 項目,即使已指定 appliesTo 屬性時也是如此。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> 指定載入組件時,Common Language Runtime 會搜尋的子目錄。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