3rd方库引用不同版本的log4net.dll
我有两个对我的应用程序至关重要的不同库,它们依赖于不同版本的 log4net.dll。当我使用的第 3 方片段被调用时,尝试 bin 文件夹中的两个 dll 会出现常见错误:
无法加载文件或程序集“log4net,Version=1.2.10.0,Culture=neutral,PublicKeyToken=1b44e1d426115821”或其之一依赖关系。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040)
有没有办法让应用程序可以引用这两个 dll?第三方 dll 是 Windsor 的 IOC 容器和 Paypal 的 API,两者都对此应用程序至关重要。
I have two different libraries critical to my application that are dependent on different versions of log4net.dll. Trying both dll's in my bin folder give the usual error when the 3rd party piece I'm using gets called:
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Is there a way that the application can reference both dll's? The third party dll's are Windsor's IOC container and Paypal's API, both critical to this application.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个问题可能有一些对您有帮助的答案。
在同一解决方案中引用 2 个不同版本的 log4net
另外,如果 Windsor 的日志记录工具依赖于 log4net 而不是 Windsor 本身,您也许可以根据 PayPal API 使用的 log4net 版本编写自己的 log4net 抽象,并告诉 Windsor 使用它。
以下是 Castle 源代码存储库中 log4net 抽象的位置:
https://github.com/castleproject/ Castle.Core/tree/master/src/Castle.Services.Logging.log4netIntegration
我不使用 Castle,所以我无法告诉你如何配置它来引用你自己的 log4net 抽象,但我打赌它也不是太困难(假设这是可能的)。
这是关于 SO 的另一篇文章的链接,该文章描述了使用 log4net 配置 Castle。它还简要讨论了编写自定义日志记录工具:
使用 Castle.Facilities 进行日志记录。日志记录和 log4net
祝你好运!
This question might have some answers that will help you.
Referencing 2 different versions of log4net in the same solution
Alternatively, if it is Windsor's Logging Facility that is dependent on log4net and not Windsor itself, you might be able to write your own log4net abstraction based on the version of log4net used by the PayPal API and tell Windsor to use that instead.
Here is the location of the log4net abstraction in Castle's source code repository:
https://github.com/castleproject/Castle.Core/tree/master/src/Castle.Services.Logging.log4netIntegration
I don't use Castle so I cannot tell you how to configure it to reference your own log4net abstraction, but I bet it is not too difficult (assuming it is possible).
Here is a link to another post here on SO that describes configuring Castle with log4net. It also talks briefly about writing a custom logging logging facility:
Logging with Castle.Facilities.Logging and log4net
Good luck!
我认为,还有一条路可走,但我自己从未这样做过,那就是将它们放入 GAC 中。
我相信您可以在 GAC 中拥有同一 dll 的不同版本,并且应该没问题。
但我也可能疯了:)
Another route to go, I think, but I've never done it myself, is putting them in the GAC.
I believe you can have different versions of the same dll in the GAC, and you should be ok.
But I also might be crazy :)