<runtime> 的 <assemblyIdentity> 元素

包含有关程序集的标识信息。

configuration
  runtime
    <assemblyBinding>
      <dependentAssembly>
        <assemblyIdentity>

语法

   <assemblyIdentity
name="assembly name"  
publicKeyToken="public key token"  
culture="assembly culture"/>  

特性和元素

下列各节描述了特性、子元素和父元素。

特性

属性 描述
name 必需的特性。

程序集的名称
culture 可选特性。

指定程序集的语言和国家/地区的字符串。
publicKeyToken 可选特性。

指定程序集的强名称的十六进制值。
processorArchitecture 可选特性。

值“x86”、“amd64”、“msil”或“ia64”之一,为包含特定于处理器的代码的程序集指定处理器体系结构。 值不区分大小写。 如果为该属性分配了任何其他值,则将忽略整个 <assemblyIdentity> 元素。 请参阅 ProcessorArchitecture

processorArchitecture 属性

说明
amd64 仅限 AMD x86-64 体系结构。
ia64 仅限 Intel Itanium 体系结构。
msil 不特定于处理器和每字位数。
x86 32 位 x86 处理器,位于本机上或位于 64 位平台的 Windows on Windows (WOW) 环境中。

子元素

无。

父元素

元素 说明
assemblyBinding 包含有关程序集版本重定向和程序集位置的信息。
configuration 公共语言运行时和 .NET Framework 应用程序所使用的每个配置文件中的根元素。
dependentAssembly 封装每个程序集的绑定策略和程序集位置。 为每个程序集使用一个 <dependentAssembly> 元素。
runtime 包含有关程序集绑定和垃圾回收的信息。

注解

每个 <dependentAssembly> 元素都必须有一个 <assemblyIdentity> 子元素。

如果 processorArchitecture 属性存在,则 <assemblyIdentity> 元素仅适用于具有相应处理器体系结构的程序集。 如果 processorArchitecture 属性不存在,则 <assemblyIdentity> 元素适用于具有任何处理器体系结构的程序集。

下面的示例显示了两个具有相同名称的程序集的配置文件,这两个程序集针对两个不同的处理器体系结构,并且其版本尚未保持同步。当应用程序在 x86 平台上执行时,应用第一个 <assemblyIdentity> 元素,忽略另一个元素。 如果应用程序在 x86 或 ia64 以外的平台上执行,则会忽略两者。

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <dependentAssembly>  
            <assemblyIdentity name="MyAssembly"  
                  publicKeyToken="14a739be0244c389"  
                  culture="neutral"  
                  processorArchitecture="x86" />  
            <bindingRedirect oldVersion= "1.0.0.0"
                  newVersion="1.1.0.0" />  
         </dependentAssembly>  
         <dependentAssembly>  
            <assemblyIdentity name="MyAssembly"  
                  publicKeyToken="14a739be0244c389"  
                  culture="neutral"
                  processorArchitecture="ia64" />  
            <bindingRedirect oldVersion="1.0.0.0"
                  newVersion="2.0.0.0" />  
         </dependentAssembly>  
      </assemblyBinding>  
   </runtime>  
</configuration>  

如果配置文件包含没有 processorArchitecture 属性的 <assemblyIdentity> 元素,也不包含与平台匹配的元素,则使用没有 processorArchitecture 属性的元素。

示例

下面的示例演示如何提供有关程序集的信息。

<configuration>  
   <runtime>  
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">  
         <dependentAssembly>  
            <assemblyIdentity name="myAssembly"  
                              publicKeyToken="32ab4ba45e0a69a1"  
                              culture="neutral" />  
            <!--Redirection and codeBase policy for myAssembly.-->  
         </dependentAssembly>  
      </assemblyBinding>  
   </runtime>  
</configuration>  

请参阅