Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

log4net

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.

like image 516
Joe B. Avatar asked Dec 07 '10 20:12

Joe B.


2 Answers

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!

like image 148
wageoghe Avatar answered Nov 12 '22 08:11

wageoghe


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 :)

like image 1
CubanX Avatar answered Nov 12 '22 07:11

CubanX