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

clog4net

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.

Best Answer

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!