I'm very new to this so I apologise if my question isn't well structured or just in the wrong place, etc. I've had a good look for solutions to this and tried a number of different approaches but haven't found anything that works so....
我很新,所以我道歉,如果我的问题不是结构良好或者只是在错误的地方,等。我有一个很好的寻找解决这些问题的办法,尝试了许多不同的方法,但是没有找到任何工作....
I have a solution that makes use of Nhibernate, and consequently must use log4net V1.2.10.0, which comes in the log4net/2.0/ folder. However my solution also links to a number of other solutions, to which I have very limited access. These make use of the same log4net V.1.2.10.0 but in folder: log4net/1.2/
我有一个使用Nhibernate的解决方案,因此必须使用log4net V1.2.10.0,它来自log4net/2.0/文件夹。然而,我的解决方案也链接到许多其他的解决方案,我的访问权限非常有限。使用相同的log4net .1.2.10.0,但在文件夹:log4net/1.2/。
When I run my solution I get this error.
当我运行我的解时,我得到这个错误。
{"Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=e27b8fa57f63a98d' or one of its dependencies. The located assembly's
manifest definition does not match the assembly reference. (Exception from HRESULT:
0x80131040)":"log4net, Version=1.2.10.0, Culture=neutral,
PublicKeyToken=e27b8fa57f63a98d"}
I have tried to amend the solutions that it is calling, however each time I amend one I get the error within that solution as soon as it tries to use another solution, so I have to amend another and so on. There are simply too many solutions to amend and too many interdepencies with other solutions that I have absolutely no control over for me to be able to change them all so that they use log4net/2.0.
我试着修改它所调用的解决方案,但是每次我修改其中一个,我就会在它尝试使用另一个解决方案时得到这个解决方案中的错误,所以我必须修改另一个,以此类推。有太多的解决方案需要修改,太多的相互依赖与其他的解决方案,我完全无法控制,我可以改变它们,所以他们使用log4net/2.0。
I have found another question ( Referencing 2 different versions of log4net in the same solution ) which I think is basically the same problem, and they amend the app.config with a binding, however I can't seem to get this right, as I'm still getting the same error. The binding I've included in my app.config is this:
我发现了另一个问题(在相同的解决方案中引用了两个不同版本的log4net),我认为这基本上是同一个问题,并且他们用绑定修改了app.config,但是我似乎不能正确地解决这个问题,因为我仍然有相同的错误。我在app.config中包含的绑定是这样的:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="e27b8fa57f63a98d" />
<codeBase version="1.2.10.0" href="2.0\log4net.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821"/>
<codeBase version="1.2.10.0" href="1.2\log4net.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
I'm not sure what the answer to the other question means when it says "You create 2 folder in your project one for each version of log4net. You 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." And would I need to do this to every solution that my solution references?
我不知道这个问题的答案是什么意思,当它说“你为每个版本的log4net创建两个文件夹”。你把每个log4net。在其相应的文件夹中添加一个文件到解决方案中(而不是添加引用)。您可以将副本设置为output目录属性,以便在构建时将其自动复制到输出文件夹。我是否需要对我的解决方案引用的每个解决方案都这样做?
Ideally I want to be able to make an amendment to my solution which simply means that it doesn't care what log4net any of the solutions are using but they can still pass log messages between each other. I assume this is possible, so any help would be hugely appreciated. Either that or how do I turn off nHibernate's logger so that it doesn't care what log4net I'm using so I can just continue to use the log4net/1.2 that all the other solutions are using. I've tried all sorts of things to turn it off but it still seems to end up trying to find the log4net/2.0.
理想情况下,我希望能够对我的解决方案进行修改,这仅仅意味着它不关心任何解决方案使用的log4net,但是它们仍然可以在彼此之间传递日志消息。我认为这是可能的,因此任何帮助都将得到极大的赞赏。或者我如何关闭nHibernate的日志程序,这样它就不会关心我使用的log4net,所以我可以继续使用log4net/1.2,所有其他的解决方案都在使用。我尝试过各种各样的方法来关闭它,但它似乎仍然试图找到log4net/2.0。
1 个解决方案
#1
1
You're lucky in that you've got the same DLL in two different places, which makes your problem easier to solve. You could simply take a back up and then delete one of the references of the DLL (the \1.2\ version?) and then resolve any broken references in your solution - that should get you to a point that you can compile.
幸运的是,在两个不同的地方都有相同的DLL,这使您的问题更容易解决。您可以简单地后退一步,然后删除DLL的一个引用(\1.2\ version?),然后解析解决方案中的任何损坏的引用——这将使您达到一个可以编译的点。
Have you tried NuGet too? You could add a reference to Log4Net and then add a reference to Nhibernate, which would see that you've already satisfied it's dependency requirement and would not need to download another reference to NHibernate.
你也试过NuGet吗?您可以添加对Log4Net的引用,然后添加对Nhibernate的引用,这将看到您已经满足了它的依赖需求,并且不需要下载另一个关于Nhibernate的引用。
I'd recommend the learning curve of using NuGet because it is a powerful tool that should make your life much easier in the long run.
我推荐使用NuGet的学习曲线,因为它是一个强大的工具,可以让你的生活从长远来看更容易。
Update Please see my comment about providing your current folder structure to help - incase you can do that; the following should get you started.
更新请查看我的评论,提供您当前的文件夹结构以帮助- incase您可以做到;下面的内容会让你开始。
To try and do this using just direct file references you may need to move your DLL's around into a better structure. Inside your solution (not project) create the following folder structure under solution items.
要尝试使用直接的文件引用来实现这一点,您可能需要将DLL的周围移动到一个更好的结构中。在您的解决方案中(不是项目)在解决方案项下创建以下文件夹结构。
\ExternalReferences \Log4Net\ \NHibernate\
\ ExternalReferences \ Log4Net \ \ NHibernate \
Move a single copy of the log4net DLL inside the log 4 net folder (and delete the other instance) and then move all the NHibernate DLL's you are using (minus Log4Net) in the NHibernate directory. Remove the bindings inside your app.config and then go through each project updating the references to point to the version inside the external references.
将log4net DLL的一个副本移动到log4网络文件夹(并删除另一个实例),然后在NHibernate目录中移动所有的NHibernate DLL (- log4net)。删除app.config中的绑定,然后遍历每个项目更新引用,以指向外部引用中的版本。
The actual location of the files isn't that important, you just need your code to reference a single instance of the DLL and then when it builds they all get copied into the bind folder. You're just running into problems because you have two instances - whilst you are editing your code, etc. NHibernate isn't actually too bothered where Log4Net is; it just has a dependency on it that must be forfilled when it runs.
文件的实际位置并不是那么重要,您只需要您的代码来引用DLL的单个实例,然后当它构建时,它们都被复制到bind文件夹中。您只是遇到了问题,因为您有两个实例—当您在编辑代码的时候,等等。NHibernate并不是很麻烦,因为Log4Net在哪里;它只是对它有一个依赖,当它运行时,它必须被填充。
Update 2
更新2
New Version of Log4Net on NuGet that breaks backward compatibility - see the referenced blog post for more info. There is now a 1.2.11.0 version of Log4Net that contains a different strong name to 1.2.10.0, making things just that little harder!
在NuGet上新版本的Log4Net打破了向后兼容性——更多信息参见参考博客文章。现在有一个1.2.11.0版本的Log4Net,它包含一个不同的强名称到1.2.10.0,使事情变得更加困难!
#1
1
You're lucky in that you've got the same DLL in two different places, which makes your problem easier to solve. You could simply take a back up and then delete one of the references of the DLL (the \1.2\ version?) and then resolve any broken references in your solution - that should get you to a point that you can compile.
幸运的是,在两个不同的地方都有相同的DLL,这使您的问题更容易解决。您可以简单地后退一步,然后删除DLL的一个引用(\1.2\ version?),然后解析解决方案中的任何损坏的引用——这将使您达到一个可以编译的点。
Have you tried NuGet too? You could add a reference to Log4Net and then add a reference to Nhibernate, which would see that you've already satisfied it's dependency requirement and would not need to download another reference to NHibernate.
你也试过NuGet吗?您可以添加对Log4Net的引用,然后添加对Nhibernate的引用,这将看到您已经满足了它的依赖需求,并且不需要下载另一个关于Nhibernate的引用。
I'd recommend the learning curve of using NuGet because it is a powerful tool that should make your life much easier in the long run.
我推荐使用NuGet的学习曲线,因为它是一个强大的工具,可以让你的生活从长远来看更容易。
Update Please see my comment about providing your current folder structure to help - incase you can do that; the following should get you started.
更新请查看我的评论,提供您当前的文件夹结构以帮助- incase您可以做到;下面的内容会让你开始。
To try and do this using just direct file references you may need to move your DLL's around into a better structure. Inside your solution (not project) create the following folder structure under solution items.
要尝试使用直接的文件引用来实现这一点,您可能需要将DLL的周围移动到一个更好的结构中。在您的解决方案中(不是项目)在解决方案项下创建以下文件夹结构。
\ExternalReferences \Log4Net\ \NHibernate\
\ ExternalReferences \ Log4Net \ \ NHibernate \
Move a single copy of the log4net DLL inside the log 4 net folder (and delete the other instance) and then move all the NHibernate DLL's you are using (minus Log4Net) in the NHibernate directory. Remove the bindings inside your app.config and then go through each project updating the references to point to the version inside the external references.
将log4net DLL的一个副本移动到log4网络文件夹(并删除另一个实例),然后在NHibernate目录中移动所有的NHibernate DLL (- log4net)。删除app.config中的绑定,然后遍历每个项目更新引用,以指向外部引用中的版本。
The actual location of the files isn't that important, you just need your code to reference a single instance of the DLL and then when it builds they all get copied into the bind folder. You're just running into problems because you have two instances - whilst you are editing your code, etc. NHibernate isn't actually too bothered where Log4Net is; it just has a dependency on it that must be forfilled when it runs.
文件的实际位置并不是那么重要,您只需要您的代码来引用DLL的单个实例,然后当它构建时,它们都被复制到bind文件夹中。您只是遇到了问题,因为您有两个实例—当您在编辑代码的时候,等等。NHibernate并不是很麻烦,因为Log4Net在哪里;它只是对它有一个依赖,当它运行时,它必须被填充。
Update 2
更新2
New Version of Log4Net on NuGet that breaks backward compatibility - see the referenced blog post for more info. There is now a 1.2.11.0 version of Log4Net that contains a different strong name to 1.2.10.0, making things just that little harder!
在NuGet上新版本的Log4Net打破了向后兼容性——更多信息参见参考博客文章。现在有一个1.2.11.0版本的Log4Net,它包含一个不同的强名称到1.2.10.0,使事情变得更加困难!