避免集引用问题一般 [英] Avoid assembly reference problems generally

查看:171
本文介绍了避免集引用问题一般的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了很多,但没能找到解决的办法呢。

I've searched a lot but wasn't able to find a solution yet.

我们有很多方案,我们的客户在一个目录共享库(DLL)中。但是,如果一个人的lib得到一个更新,我们必须重新编译它们指的DLL的所有程序。如果我们不这样做,我们的客户获取是从调用的lib函数(<一个错误时href="http://stackoverflow.com/questions/215026/the-located-assemblys-manifest-definition-does-not-match-the-assembly-reference?rq=1">The位于集清单定义不匹配的程序集引用)。

We have a lot of programs for our clients with shared libs (dlls) in one directory. But if one lib gets an update we have to recompile all programs which are refering the dll. If we don't, our client get's an error when calling a function from the lib (The located assembly's manifest definition does not match the assembly reference).

我们想引用一个lib像往常一样,当一个lib获取的升级程序应该使用抛出一个错误,新版本代替。

We would like to reference a lib as usual and when a lib get's upgraded the programs should just use the new version instead of throwing an error.

问题的部分原因是,该基准是内部固定带版本号。我的第一个想法就是指的之前删除DLL的版本号。但是,即使可能吗?

Part of the problem is, that the reference is internally fixed with an version-number. My first idea is to remove the version number of the dll before refering. But is that even possible?

我将不胜感激任何(其他)意见或建议如何绕过引用问题。这可能是重复的,但我并没有找到一个解决方案后 - 刚刚发布的,它描述的原因

I would be grateful for any (other) ideas or suggestions how to bypass the reference problem. This may be a duplicate but I didn't yet find a post with an solution - just post's which describe the reasons.

推荐答案

什么程序集绑定重定向 - 的 https://msdn.microsoft.com/en-us/library/433ysdt1(V = vs.110)的.aspx (的多了一个MSDN链接)?

What about assembly binding redirection - https://msdn.microsoft.com/en-us/library/433ysdt1(v=vs.110).aspx (one more msdn link) ?

您可以在配置重定向到新版本中指定,所以它不会需要重新编译。但是,如果类,您使用的是\方法签名将被改变 - 那么它无论如何都会抛出一个异常

You can specify in the config redirection to a new version, so it wont require recompile. But if signature of classes\methods that you are using will be changed - then it will throw an exception anyway.

ASP.Net MVC使用这种方法来指定重定向到一个新版本的MVC的:

ASP.Net MVC uses this approach to specify redirection to a new version of MVC:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
        </dependentAssembly>
        <dependentAssembly>
            <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="4.5.0.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

这篇关于避免集引用问题一般的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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