我如何解决 log4net 不断更改 publickeytoken [英] how do I work around log4net keeping changing publickeytoken

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

问题描述

我们有一个 asp.net 4.0 项目,它使用了几个依赖于 log4net 版本 1.2.10.0 的框架.今天我尝试包含一个依赖于 log4net 版本 1.2.11.0 的新框架,从那以后我一直被困:

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 有 publickeytoken = 1b44e1d426115821

log4net 1.2.10.0 has publickeytoken = 1b44e1d426115821

log4net 1.2.11.0 有 publickeytoken = 669e0ddf0bb1aa2a

log4net 1.2.11.0 has publickeytoken = 669e0ddf0bb1aa2a

由于这些不同,我不能通过 web.config 中的运行时元素使用程序集重定向(使所有框架使用相同版本的 log4net)或代码库(让新框架使用版本 1.2.11.0).

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.

我有哪些选择?

(以及为什么 log4net 会在版本之间不断更改 publickeytokens 的哔哔声,据我所知,丢失的密钥是在 1.2.9.0 和 1.2.10.0 版本之间切换的原因,他们是否又丢失了密钥?我会如果他们需要,自愿使用我的保管箱来保证它的安全...)

(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...)

好的,所以 log4net 人员显然认为使用两个密钥发布是一个好主意,但这意味着您使用的每个框架都需要就哪个框架达成一致 他们喜欢的两种风格,或者这些框架不能在同一个应用程序域中并行工作.只有我觉得这是一个可怕的想法吗?如果每个人都这样做,那么一切都会崩溃,对吗?

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:正如我所说,我没有在我的业务代码中使用 log4net,但我使用了几个依赖于 1.2.10.0 的框架,当我尝试使用依赖于 1.2.11.0 的新框架时出现了问题(新密钥),所以 Stefans 的回答不适用,因为新框架需要新密钥,而不是旧密钥

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

推荐答案

这就是我使用 1.2.11.0 版本的方式.

This is how I got things working with version 1.2.11.0.

  1. 首先诅咒 apache 更改密钥:)
  2. 下载 使用旧密钥签名的 1.2.11.0 版本.
  3. 通过删除对 log4net(新密钥)的任何直接引用并替换为对使用旧密钥签名的程序集的引用来整理您自己的代码.
  4. 通过在您的 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 不断更改 publickeytoken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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