1.<assemblyIdentity> 元素
包含关于该程序集的标识信息。
<assemblyIdentity name="assembly name" publicKeyToken="public key token" culture="assembly culture"/>
下列各节描述了特性、子元素和父元素。
|
特性 |
说明 |
|---|---|
|
name |
必需的特性。 程序集的名称 |
|
culture |
可选特性。 指定程序集的语言和国家/地区的字符串。 |
|
publicKeyToken |
可选特性。 指定程序集强名称的十六进制值。 |
|
processorArchitecture |
可选特性。 ProcessorArchitecture。 |
processorArchitecture 特性
|
值 |
说明 |
|---|---|
|
amd64 |
仅 64 位 AMD 处理器。 |
|
ia64 |
仅 64 位 Intel 处理器。 |
|
msil |
不特定于处理器和每字位数 |
|
x86 |
32 位 Intel 处理器,位于本机上或位于 64 位平台上的 Windows on Windows (WOW) 环境中。 |
子元素
无。
父元素
|
元素 |
说明 |
|---|---|
|
assemblyBinding |
包含有关程序集版本重定向和程序集位置的信息。 |
|
configuration |
每个配置文件中的根元素,常用语言 runtime 和 .NET Framework 应用程序会使用这些文件。 |
|
dependentAssembly |
<dependentAssembly> 元素。 |
|
runtime |
包含程序集绑定和垃圾回收的相关信息。 |
备注
每个 <dependentAssembly>元素都必须有一个<assemblyIdentity> 子元素。
<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>
2.<bindingRedirect> 元素
将一个程序集版本重定向到另一个版本。
<bindingRedirect oldVersion="existing assembly version" newVersion="new assembly version"/>
下列各节描述了特性、子元素和父元素。
特性
|
特性 |
说明 |
|---|---|
|
oldVersion |
必需的特性。 该版本号的每个部分的有效值介于 0 和 65535 之间。 你还可以按下列格式指定版本范围: n.n.n.n - n.n.n.n |
|
newVersion |
必需的特性。 n.n.n.n) oldVersion 之前的版本。 |
子元素
父元素
|
元素 |
说明 |
|---|---|
|
assemblyBinding |
包含有关程序集版本重定向和程序集位置的信息。 |
|
configuration |
每个配置文件中的根元素,常用语言 runtime 和 .NET Framework 应用程序会使用这些文件。 |
|
dependentAssembly |
为每个程序集使用一个 dependentAssembly 元素。 |
|
runtime |
包含程序集绑定和垃圾回收的相关信息。 |
备注
运行时如何定位程序集。
你还可从程序集的更新版本重定向到较旧版本。
程序集绑定重定向安全权限。
示例
下面的示例演示如何将一个程序集版本重定向到另一个版本。
<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"/> </dependentAssembly> </assemblyBinding> </runtime> </configuration>