使用不同版本的参考DLL [英] Use different versions of referenced DLL

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

问题描述

不知怎的,我很幸运,从来没有来处理这个问题,尽管我认为这是一个常见的​​:

Somehow I've been lucky and never had to deal with this problem, even though I think it's a common one:

我有一个Web项目,姑且称之为 SomeProject SomeProject 引用了第三方库,姑且称之为 SomeThirdParty ,1.0版。 SomeProject 还引用了一个土生土长的类库,我们称之为 SomeLibrary SomeLibrary 也有一个参考 SomeThirdParty ,但不同的版本(假设2.0)。

I've got a web project, let's call it SomeProject. SomeProject has a reference to a 3rd party library, let's call it SomeThirdParty, version 1.0. SomeProject also has a reference to a home-grown class library, let's call it SomeLibrary. SomeLibrary also has a reference to SomeThirdParty, but a different version (let's say 2.0).

1.0和2.0版本的 SomeThirdParty 共享了许多相同的签名,但有不同的实现。我需要 SomeProject 使用1.0实现,而 SomeLibrary 使用2.0实现可能的话。

Version 1.0 and 2.0 of SomeThirdParty share most of the same signatures, but are different implementations. I need SomeProject to use the 1.0 implementation, and SomeLibrary to use the 2.0 implementation if possible.

我编译 SomeProject 利用其参考log4net的。结束了在bin目录下的DLL是一个 SomeProject 引用。在运行时,从 SomeLibrary code运行时,它试图从 SomeThirdParty ,当然失败时,抛出一个 FileLoadException:未能加载文件或程序集 SomeThirdParty ,版本= 2.0.0.0,文化= [等]或它的某一个依赖。找到的程序集清单定义不匹配的程序集引用。

I compile SomeProject using its reference to log4net. The DLL that ends up in the bin directory is the one that SomeProject references. At runtime, when code from SomeLibrary runs, it attempts to execute the code from version 2.0 of SomeThirdParty, and of course fails, throwing a FileLoadException: Could not load file or assembly 'SomeThirdParty, Version=2.0.0.0, Culture=[etc.]' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

很显然,我可以升级 SomeProject 到较新的DLL或降级 SomeLibrary 到旧的DLL,但它不会告发 T为理想的原因是多方面的。

Obviously I could upgrade SomeProject to the newer DLL or downgrade SomeLibrary to the older DLL, but it wouldn't be ideal for many reasons.

我认为正确的答案涉及在GAC安装SomeThirdParty,但我不知道究竟我会去这样做,它会如何影响其他开发人员和服务器。

I think the right answer involves installing SomeThirdParty in the GAC, but I'm not sure exactly how I'd go about doing this, and how it would affect other developers and servers.

如果您有任何的建议是AP preciated。

Any suggestions you may have are appreciated.

感谢您的帮助。

推荐答案

把SomeThirdParty的两个版本到GAC应该做你想要什么。使用GACUTIL实用程序或开始 - >运行 - >组装然后将正下降。

Putting both versions of SomeThirdParty into GAC should do what you want. Use gacutil utility or Start->Run->assembly then drag-n-drop.

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

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