Log4net public token issues (could not load file or assembly)

We have some packages (and external modules) which we use who are using log4net.
But after installing these packages we have the following error:
Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Apparently umbraco depends on a log4net version without public key and the log4net (nuget package) has public key.

To use both log4net assemblies I solved this like this:

  1. get the umbraco version of log4net.dll and move it to a new folder: bin\log4net-1.2.11-nokey
  2. pull the new log4net nuget package (which is signed with a new key)
  3. Add the code below to the assemblyBinding section of the web.config:

if you recompiled the log4net dll, you might need to update the publicKeyToken (you can use dotpeek or ILspy to find the publicKey easily.

<dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="null" culture="neutral"  />
        <codeBase version="1.2.11.0" href="bin\log4net-1.2.11-nokey\log4net.dll" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" />
          <bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="1.2.11.0"/>
          <codeBase version="1.2.11.0" href="log4net.dll" />
      </dependentAssembly>

Hope it helps someone!


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/45996-log4net-public-token-issues-could-not-load-file-or-assembly