升级在C#项目的引用的DLL而无需重新编译项目 [英] Upgrade a reference dll in a C# project without recompiling the project

查看:2597
本文介绍了升级在C#项目的引用的DLL而无需重新编译项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个C#应用程序的内置版本,并改变参考dll的之一。什么是做到这一点的最好办法,我特定版本关闭上的参考DLL但只要我测试用较新版本替换该dll,我得到无法加载文件或程序XXXXX,版本= XXXXX。是有没有办法从关心的DLL版本停止装载机所以DLL将只是尝试加载?

I need to take a built version of an C# application and change one of the reference dll's. What is the best way to do this, I have specific version turned off on the reference dll but as soon as I test replacing the dll with a newer version, I get the "Could not load file or assembly XXXXX, Version=XXXXX. Is there a way to stop the loader from caring about the version of the dll so the dll will just attempt to load?

推荐答案

是的,你可以做到这一点 - 请参阅MSDN文章重定向程序集版本的。

Yes, you can do this - see the MSDN article Redirecting Assembly Versions.

您应该阅读整个文档,但它本质上涉及任何组装的发行创造一个发行者策略文件'或消费者加入 bindingRedirect 的app.config 文件,就像这样(直接从文章复制):

You should read the whole document, but it essentially involves either the assembly's publisher creating a 'publisher policy file' or the consumer adding a bindingRedirect to an app.config file, like this (copied directly from the article):

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
         <assemblyIdentity name="myAssembly"
                           publicKeyToken="32ab4ba45e0a69a1"
                           culture="en-us" />
         <bindingRedirect oldVersion="1.0.0.0"
                          newVersion="2.0.0.0"/>
       </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>



的几个注意事项:

A few notes:


  • 如果你没有明确指定
    你的文化(因为很多人没有),它将
    为中性,而不是EN-US。

  • If you haven't explicitly specified your culture (as many don't), it will be "neutral" rather than "en-us".

如果您不知道的话,你可以
使用强名称工具得到大会的公钥标记
,如
本: SN-T [AssemblyPath]

If you don't already know it, you can get the assembly's public key token using the strong name utility, like this: sn -t [AssemblyPath]

这篇关于升级在C#项目的引用的DLL而无需重新编译项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆