Chapter3 ~ Assembly control management

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.