在同一解决方案中引用2个不同版本的log4net [英] Referencing 2 different versions of log4net in the same solution

查看:325
本文介绍了在同一解决方案中引用2个不同版本的log4net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用引用了log4net 1.2.10.0的NHibernate 2.1.2.400。
在同一个项目中,我也使用简单的会计SDK,可惜的是仍然使用log4net 1.2.9.0。



所以我可以让NHibernate工作我引用log4net 1.2.10.0,但是simpleSDK不起作用。反之亦然...



我猜测大部分问题来自于log4net已经更改了程序集的事实。我尝试使用绑定重定向没有成功:2个DLL没有相同的键。



我正在考虑重新编译NHibernate使用log4net 1.2.9.0,但似乎错误的事情和我的感觉是,简单会计将不会更新他们的SDK,以便使用log4net 1.2.10.0。



什么是最好的方法来处理这个?是否可以解决?

解决方案

我使用这个回答类似的问题



您可以为每个版本的log4net在项目中创建2个文件夹。将每个log4net.dll放在相应的文件夹中,方法是将该文件添加到解决方案中(而不是添加引用)。您可以将副本设置为输出目录属性以始终复制,以便在构建时自动将其复制到输出文件夹。



然后,您可以修改app.config文件添加如下内容:

 < configuration> 
<运行时>
< assemblyBinding xmlns =urn:schemas-microsoft-com:asm.v1>
< dependentAssembly>
< assemblyIdentity name =log4netpublicKeyToken =681549d62126b7b8/>
< codeBase version =1.2.9.0href =log4netv1.2.9.0\log4net.dll/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity name =log4netpublicKeyToken =1b44e1d426115821/>
< codeBase version =1.2.10.0href =log4netv1.2.10.0\log4net.dll/>
< / dependentAssembly>
< dependentAssembly>
< assemblyIdentity name =log4netpublicKeyToken =669e0ddf0bb1aa2a/>
< codeBase version =1.2.11.0href =log4net.dll/>
< / dependentAssembly>
< / assemblyBinding>
< / runtime>
< / configuration>

您可以使用sn -T [assemblyName]获得程序集的公钥令牌


I'm using NHibernate 2.1.2.400 that is referencing log4net 1.2.10.0. In the same project, I also use the simply accounting SDK, sadly it is still using log4net 1.2.9.0.

So I can get NHibernate to work if I reference log4net 1.2.10.0 but the simplySDK don't work. And vice versa...

I'm guessing most of the problems come from the fact that log4net has changed its assembly key. I tried using a binding redirection without success: the 2 DLLs do not have the same key.

I'm considering recompiling NHibernate to use log4net 1.2.9.0 but it seems like the wrong thing to do and my feeling is that Simply Accounting won't be updating their SDK to use log4net 1.2.10.0 anytime soon.

What is the best way to handle this? Is it possible to resolve at all?

解决方案

I found the solution by using this answer to a similar question

You create 2 folders in your project one for each version of log4net. Place each log4net.dll in its corresponding folder by adding an the file to the solution (not with add reference). You can set the copy to output directory property to copy always so that it is automatically copied to the output folder when you build.

Then you modifiy the app.config file by adding something like this:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="681549d62126b7b8" />
        <codeBase version="1.2.9.0" href="log4netv1.2.9.0\log4net.dll" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" />
        <codeBase version="1.2.10.0" href="log4netv1.2.10.0\log4net.dll" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" />
        <codeBase version="1.2.11.0" href="log4net.dll" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

you can get the public key token of an assembly by using sn -T [assemblyName]

这篇关于在同一解决方案中引用2个不同版本的log4net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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