引用log4net的2型动物版本在同一溶液 [英] Referencing 2 differents versions of log4net in the same solution

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

问题描述

我使用NHibernate 2.1.2.400被引用log4net的1.2.10.0。 在同一个项目中,我也用简单的会计SDK,遗憾的是它依然使用的log4net 1.2.9.0。

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.

所以,我可以得到的NHibernate来,如果我引用log4net的1.2.10.0但simplySDK不起作用工作。反之亦然......

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

我猜大部分的问题都来自log4net的改变了它的组件,关键的事实。我试图用一个绑定重定向没有成功:2个dll文件不具有相同的密钥

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

我在考虑重新编译的NHibernate使用log4net的1.2.9.0,但它似乎是错误的做法,我的感觉是,只要会计不会很快更新其SDK使用log4net的1.2.10.0。

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 very quick to update their SDK to use log4net 1.2.10.0.

我使用的是.NET 4.0

I'm using .net 4.0

可以用一个探测私人路径app.config文件帮助?

Could using a probing private path in the app.config file help?

什么是处理这一问题的最佳方法是什么?是否有可能解决呢?

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

您创建2个文件夹在你的项目中为每个版本的log4net的。通过添加文件到解决方案(不加引用)将在其对应的文件夹中的每个log4net.dll。您可以设置复制到输出目录属性复制总是这样,它会自动复制到输出文件夹,当你构建。

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.

然后你加入这样的事情modifiy app.config文件:

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>

您可以通过使用SN得到一个程序集的公钥标记-T [的AssemblyName]

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

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

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