引用相同程序集的不同版本
如果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?
在我的情况下,因为我正在使用第三方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.
另外,你读过这个吗?