引用同一程序集的不同版本 [英] Referencing different versions of the same assembly

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

问题描述

如果 A 引用程序集 B 1.1 和 C,而 C 引用 B 1.2,您如何避免程序集冲突?

If A references assembly B 1.1 and C, and C references B 1.2, how do you avoid assembly conflicts?

我一直认为 C 的引用会被封装掉并且不会引起任何问题,但似乎所有的 dll 都被复制到了 bin 中,这就是问题发生的地方.

I nievely assumed C's references would be encapsulated away and would not cause any problems, but it appears all the dll's are copied to the bin, which is where the problem occurs.

我了解解决此问题的两种方法是使用 GAC 还是程序集绑定?GAC 对我来说似乎不是最好的方法,因为我不喜欢假设 dll 会在那里,我更喜欢从我的解决方案中的 lib 目录中引用 dll.

I understand the two ways around this are to use the GAC or assembly bindings? The GAC doesn't seem like the best approach to me, as I don't like assuming dlls will be there, I prefer to reference dlls from a lib directory in my solution.

因为程序集绑定对我来说似乎不够健壮,如果程序集的一个版本具有另一个版本没有的功能,这会不会产生问题?

Where as assembly bindings don't seem robust to me, what if one version of the assembly has functionality that the other doesn't, will this not produce problems?

就我而言,这是因为我使用的是第 3 方 dll 使用的 nHibernate 的旧版本,而不是我自己使用的版本.

In my case its because I'm using a 3rd party dll uses a older version of nHibernate, than I'm using myself.

推荐答案

我过去使用 GAC 也取得了相同的结果,但是您应该质疑您必须引用多个版本的原因并尽量避免它如果可能的话.如果您必须这样做,绑定重定向可能帮助您解决问题.

I've achieved the same results using the GAC in the past, but you should question your reasons for having to reference more than one version and try to avoid it if possible. If you must do it, a binding redirect may help in your case.

此外,您是否已阅读这篇?

这篇关于引用同一程序集的不同版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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