简体   繁体   English

第三方库引用不同版本的log4net.dll

[英]3rd party libraries refer to different versions of log4net.dll

I have two different libraries critical to my application that are dependent on different versions of log4net.dll. 我有两个对我的应用程序至关重要的库,这些库依赖于不同版本的log4net.dll。 Trying both dll's in my bin folder give the usual error when the 3rd party piece I'm using gets called: 当我正在使用的第三方片段被调用时,尝试我的bin文件夹中的两个dll都会出现常见错误:

Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. 无法加载文件或程序集'log4net,Version = 1.2.10.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821'或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference. 定位的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (HRESULT异常:0x80131040)

Is there a way that the application can reference both dll's? 有没有办法让应用程序可以引用这两个dll? The third party dll's are Windsor's IOC container and Paypal's API, both critical to this application. 第三方dll是Windsor的IOC容器和Paypal的API,这两者对这个应用程序至关重要。

This question might have some answers that will help you. 这个问题可能会有一些帮助你的答案。

Referencing 2 different versions of log4net in the same solution 在同一解决方案中引用2个不同版本的log4net

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. 或者,如果Windsor的Logging Facility依赖于log4net而不是Windsor本身,您可以根据PayPal API使用的log4net版本编写自己的log4net抽象,并告诉Windsor使用它。

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 以下是Castle的源代码存储库中log4net抽象的位置: 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). 我不使用Castle,所以我不能告诉你如何配置它来引用你自己的log4net抽象,但我敢打赌它并不太难(假设它是可能的)。

Here is a link to another post here on SO that describes configuring Castle with log4net. 这是SO上另一篇文章的链接,描述了使用log4net配置Castle。 It also talks briefly about writing a custom logging logging facility: 它还简要介绍了如何编写自定义日志记录工具:

Logging with Castle.Facilities.Logging and log4net 使用Castle.Facilities.Logging和log4net进行日志记录

Good luck! 祝好运!

Another route to go, I think, but I've never done it myself, is putting them in the GAC. 我认为,另一条路可走,但我自己从未做过,将它们放入GAC。

I believe you can have different versions of the same dll in the GAC, and you should be ok. 我相信你可以在GAC中拥有相同dll的不同版本,你应该没问题。

But I also might be crazy :) 但我也可能疯了:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM