Make your. NET program compatible with Dll files of different versions

Source: Internet
Author: User

A WinForm. NET program written some time ago. Because many library files have been referenced, but these library files have recently corrected some bugs and algorithms. However, the main program file has not been changed. So it is not like re-compiling the main program. So we copied all the new DLL files to the running directory and hoped that the main program could directly call the new library files. It turns out that these database files are signed by Strong Name. An error occurs when the main program is called, indicating that files of this version cannot be found.

Later, I checked MSDN and found that you only need to add the runtime node to config.

<Runtime>
<AssemblyBinding xmlns = "urn: schemas-microsoft-com: asm. v1">
<DependentAssembly>
<AssemblyIdentity name = "MyAssembly"
PublicKeyToken = "2b7c3a3291de04"
Culture = "neutral"/>
<BindingRedirect oldVersion = "3.0.0.8"
NewVersion = "4.1.0.0"/>

</DependentAssembly>
</AssemblyBinding>
</Runtime>

However, the premise is that the PublicKeyToken of the two DLL is the same, that is, the signature of the same sn file is required.

Of course, if your library file does not use the Strong Name signature at all, you do not need to consider the version issue.

Related Article

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.