避免组装参考问题 [英] Avoid assembly reference problems generally

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

问题描述

我搜索了很多,但还没有找到解决方案。

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

我们为我们的客户提供了大量程序,共享库(dll)在一个目录但是如果一个lib获得更新,我们必须重新编译所有引用dll的程序。如果我们不这样做,我们的客户端从lib调用函数时就会出错(所在的程序集的清单定义与程序集引用不一致)。

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?

我会感谢任何(其他)想法或建议如何绕过参考问题。这可能是一个重复的,但我还没有找到一个解决方案的帖子 - 只是post的描述原因。

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天全站免登陆