Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

We have an asp.net 4.0 project which uses a couple of frameworks which is dependent on log4net version 1.2.10.0. Today I tried to include a new framework which is dependent on log4net version 1.2.11.0, I've been stuck ever since:

log4net 1.2.10.0 has publickeytoken = 1b44e1d426115821

log4net 1.2.11.0 has publickeytoken = 669e0ddf0bb1aa2a

Since these are different i cannot use either assembly redirects (to make all frameworks use the same version of log4net) or codebase (to have just the new framework use version 1.2.11.0) through the runtime element in web.config.

What are my options here ?

(and why the bleep does log4net keep changing publickeytokens between versions, as I understand it a lost key was the reason for the switch between version 1.2.9.0 and 1.2.10.0, did they lose the key yet again? I'll volunteer my dropbox to keep it safe if they need it...)

Edit: Ok, so the log4net guys apparently had the idea that releasing with two keys was a good idea, but that means that every framework you make use of needs to agree on which of the two flavors they prefer, or those frameworks cannot work side by side in the same appdomain. Am I the only one finding this a horrible idea? if everyone did this then everything would break down, right?

Edit2: As I stated, I'm not using log4net in my business code, but I use several frameworks which depend on 1.2.10.0, and the problem arose when I tried to use a new framework which depended on 1.2.11.0 (new key), so Stefans answer doesn't apply, because the new framework will expect the new key, not the old one

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
299 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is how I got things working with version 1.2.11.0.

  1. Curse apache for changing the key in the first place :)
  2. Download the version of 1.2.11.0 signed with the old key.
  3. Sort out your own code out by removing any direct references to log4net (new key) and replace with a reference to the assembly signed with the old key.
  4. Sort out any dependant assemblies you may have by including this segment in your web/app.config
   <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.2.10.0"
                                 newVersion="1.2.11.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...