我该如何解决log4net的保存更改公钥 [英] how do I work around log4net keeping changing publickeytoken

查看:468
本文介绍了我该如何解决log4net的保存更改公钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个asp.net 4.0的项目,它使用了几个框架,这是依赖于log4net的版本1.2.10.0。今天,我想有一个新的框架,这是依赖于log4net的版本1.2.11.0,我一直以来坚持不断:

log4net的1.2.10.0有公钥= 1b44e1d426115821

log4net的1.2.11.0有公钥= 669e0ddf0bb1aa2a

由于这些是不同的,我不能用汇编语言重定向(使所有的框架使用相同版本的log4net的)或codeBase类(以刚才的新框架使用的版本1.2.11.0)通过网络运行的元素。配置。

什么是我选择这里?

(为什么喊来确实log4net的保持版本之间的变化publickeytokens,按照我的理解一个丢失的钥匙是为1.2.9.0版本1.2.10.0之间的切换的原因,他们才失去了关键的又一次?我会志愿者我的Dropbox,以保证它的安全,如果他们需要它...)

编辑:好了,所以log4net的家伙显然也有此想法,用两个键释放是个好主意,但是这意味着的每次的框架,您使用的需要达成一致的这两种风格的的他们preFER,或者这些框架不能并排在同一个AppDomain中携手并肩。我是唯一一个这一发现一个可怕的想法?如果每个人都这样做那么一切都将打破,对吧?

EDIT2:正如我所说,我不使用log4net的在我的生意code,我却用它依赖于1.2.10.0几个框架,问题出现了,当我试图用它依赖于一个新框架1.2.11.0(新密钥),所以Stefans回答不适用,因为新的框架将预计新的密钥,而不是旧的

解决方案

这是我得到的东西与1.2.11.0版本的工作。

  1. 诅咒阿帕奇改变的关键摆在首位:)
  2. <一个href="http://www.apache.org/dyn/closer.cgi/logging/log4net/binaries/log4net-1.2.11-bin-oldkey.zip">Download与旧密钥的1.2.11.0版本签名。
  3. 排序出你自己的code OUT通过删除log4net的(新密钥)的任何直接引用,并与参考使用旧密钥签名的组件进行更换。
  4. 搜索结果排序,你可能必须通过包括该段在你的网页所有相关组件/的app.config

&LT;运行&GT;         &LT; assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1&GT;             &LT; dependentAssembly&GT;                 &LT; assemblyIdentity名=log4net的公钥=1b44e1d426115821文化=中性/&GT;                 &LT; bindingRedirect oldVersion =0.0.0.0-1.2.10.0                                  动态网页=1.2.11.0/&GT;             &LT; / dependentAssembly&GT;         &LT; / assemblyBinding&GT;     &LT; /运行&GT;

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

解决方案

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>

这篇关于我该如何解决log4net的保存更改公钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆