Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to assembly redirect log4net to newer version

I just upgraded log4net in my project and am having some assembly binding issues because a component relies on an older version of log4net.

The version expected by the component is

log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821

The version I have is

log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a

How do I cause this binding to resolve properly (there is only one api difference and it should not matter for this component).

I have tried adding the following to my web.config but it does not work.

  <dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
    <bindingRedirect oldVersion="1.2.10.0" newVersion="1.2.12.0" />
  </dependentAssembly>
like image 962
George Mauer Avatar asked Oct 15 '13 02:10

George Mauer


1 Answers

I don't believe it's possible to perform a binding redirect to an assembly with a different public key.

  1. You'll need to download the version of log4net v1.2.12.0 that is signed with the old key (http://psg.mtu.edu/pub/apache//logging/log4net/binaries/log4net-1.2.12-bin-oldkey.zip)

  2. Then update your code, replacing references to:

    log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a

    with

    log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=1b44e1d426115821

On a related note: you can put a version range in the redirect oldVersion="0.0.0.0-1.2.11.0", for added flexibility.

like image 142
2Toad Avatar answered Oct 10 '22 02:10

2Toad