Use config to manage assembly.
The following is an example
<? XML version = "1.0"?>
<Configuration>
<Runtime>
<Assemblybinding xmlns = "urn: Schemas-Microsoft-com: ASM. V1">
<Probing privatepath = "auxfiles; bin \ subdir"/>
<Dependentassembly>
<Assemblyidentity name = "mytype"
Publickeytoken = "32ab4ba45e0a69a1" Culture = "neutral"/>
<Bindingredirect
Oldversion = "1.0.0.0" newversion = "2.0.0.0"/>
<Codebase version = "2.0.0.0"
Href = "http://www.MyType.com/MyType.dll"/>
</Dependentassembly>
<Dependentassembly>
<Assemblyidentity name = "typelib"
Publickeytoken = "1f2e74e897abbcfe" Culture = "neutral"/>
<Bindingredirect
Oldversion = "3.0.0.0-3.5.0.0" newversion = "4.0.0.0"/>
<Publisherpolicy apply = "no"/>
</Dependentassembly>
</Assemblybinding>
</Runtime>
</Configuration>
The corresponding node has the following meanings:
Probing Element
Find the weak name assembly in auxfiles; bin \ subdir.
Dependentassembly, assemblyidentity, and bindingredirect Elements
Replace the value of 1.0.0.0 public key with 32ab4ba45e0a69a1 and mytype with version 2.0.
Codebase Element
Location of mytype. dll whose version is 2.0
Public policy
When you modify the previous Assembly in a very small scope, such as fixing some bugs in the previous version, you want the customerProgramAccept your changes soon.
We can modify the config or machine config as described earlier, but this is sometimes too troublesome.
At this time, we can use the public policy to adapt to this change.
First, create an independent config file named mytype. config.
<Configuration>
<Runtime>
<Assemblybinding xmlns = "urn: Schemas-Microsoft-com: ASM. V1">
<Dependentassembly>
<Assemblyidentity name = "mytype"
Publickeytoken = "32ab4ba45e0a69a1" Culture = "neutral"/>
<Bindingredirect
Oldversion = "1.0.0.0" newversion = "2.0.0.0"/>
<Codebase version = "2.0.0.0"
Href = "http://www.Mytype.com/MyType.dll/">
</Dependentassembly>
</Assemblybinding>
</Runtime>
</Configuration>
Then, open Al to create policy
Al.exe/out: policy.1.0.mytype. dll
/Version: 1.0.0.0
/Keyfile: mykey. SNK
/Linkresource: mytype. config
/Out naming is important! Specify the output file name as policy.1.0.jefftypes. dll. Policy indicates that the CLR file contains policy information. 1.0 indicates the version of the Assembly processed by the policy. Mytype indicates the corresponding Assembly name.
/Version identifies the policy version.
/Keyfile Assembly releases the corresponding key.
/Linksource corresponds to the config file name just created.
This policy can be attached to the new DLL during release without modifying the config.
It is worth noting that the other advantage of using the policy is that when the new version has problems and you want to give up, you can directly set it through config.
<Publisherpolicy apply = "no"/> indicates that the policy is blocked.