Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
617 views
in Technique[技术] by (71.8m points)

c# - 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. 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...