Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yet another issue about log4net 1.2.11 conflicts

Tags:

c#

log4net

gac

I've spent the last 2 hours looking over these issues on SO, and nothing seems to be working.

I have a solution that uses log4net 1.2.11, via NuGet. It works fine on my 32 bit development workstation running Windows 7. It does not run on my 64-bit Windows 2008 R2 test system. The error I get is:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

I am looking in the application directory on my test system. The log4net.dll file there is version 1.2.11.

The version in the GAC was version 1.2.10. I have removed it. There was a version on my development server that was yet again something else; I removed that as well. I have rebuilt; I have redeployed. I have added

<dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="669E0DDF0BB1AA2A" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="1.2.11.0"/>
</dependentAssembly>

to my configuration file. Nothing seems to make a bit of difference. My deployment project shows the right version and signature of the log4net assembly that is being deployed.

I do not know what else I can do, but I am getting quite frustrated that a logging library is preventing my application from running.

What have I missed?

like image 864
Jeremy Holovacs Avatar asked May 02 '12 15:05

Jeremy Holovacs


People also ask

Who owns log4net?

log4net is part of the Apache Logging Services project at the Apache Software Foundation.

What is log4net DLL?

dll in Solution. Log4net is an open-source project based on the work of many authors. It allows the developer to control what log statements are output with arbitrary granularity. It is fully configurable at runtime using external configuration files.


2 Answers

I had this issue after upgrading log4net through NuGet, only to find that the newer version was signed with a different key. Sigh. For some reason this only became apparent when I deployed to the live server, it didn't crop up in development.

You can grab the 'oldkey' version from the apache log4net site. Just nuke your references from the project file and reference the oldkey version instead.

like image 75
keithl8041 Avatar answered Oct 04 '22 22:10

keithl8041


Here was my solution: I changed from log4net to Common.Logging to NLog. It didn't take a lot of effort, and I don't think it should have been necessary, but it worked, and worked well.

like image 21
Jeremy Holovacs Avatar answered Oct 04 '22 23:10

Jeremy Holovacs