Yet another issue about log4net 1.2.11 conflicts

Jeremy Holovacs picture Jeremy Holovacs · May 2, 2012 · Viewed 10.6k times · Source

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?

Answer

keithl8041 picture keithl8041 · Dec 19, 2012

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.