Yet another issue about log4net 1.2.11 conflicts

旧街凉风 提交于 2019-12-22 01:52:10

问题


I've spent the last 2 hours looking over these issues on SO, and nothing seems to be working.

I have a solution that uses log4net 1.2.11, via NuGet. It works fine on my 32 bit development workstation running Windows 7. It does not run on my 64-bit Windows 2008 R2 test system. The error I get is:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'log4net, Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

I am looking in the application directory on my test system. The log4net.dll file there is version 1.2.11.

The version in the GAC was version 1.2.10. I have removed it. There was a version on my development server that was yet again something else; I removed that as well. I have rebuilt; I have redeployed. I have added

<dependentAssembly>
    <assemblyIdentity name="log4net" publicKeyToken="669E0DDF0BB1AA2A" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="1.2.11.0"/>
</dependentAssembly>

to my configuration file. Nothing seems to make a bit of difference. My deployment project shows the right version and signature of the log4net assembly that is being deployed.

I do not know what else I can do, but I am getting quite frustrated that a logging library is preventing my application from running.

What have I missed?


回答1:


I had this issue after upgrading log4net through NuGet, only to find that the newer version was signed with a different key. Sigh. For some reason this only became apparent when I deployed to the live server, it didn't crop up in development.

You can grab the 'oldkey' version from the apache log4net site. Just nuke your references from the project file and reference the oldkey version instead.




回答2:


Here was my solution: I changed from log4net to Common.Logging to NLog. It didn't take a lot of effort, and I don't think it should have been necessary, but it worked, and worked well.




回答3:


We are having the exact same issue. A dependency deep in the code base is putting 1.2.10 into the GAC and NuGet is trying to use 1.2.11. We gave up using NuGet for log4net, too much of a headache. Seems NuGet is a bit all or nothing.




回答4:


Sometimes you have to really drill down into the project dependencies. In my case it was a reference of a reference of the actual Service Stack project that was referencing a different version of Log4Net.

To fix it I added the newest version of Log4Net from nuget to the ServiceStack project. I also made sure the direct reference was using the newest version and this solved the issue.

You can use a dependency tool to quickly find which references are using conflicting versions, but if you don't have a tool for this you can just compile the project's reference by itself and see what version of log4net.dll gets copied to the directory.



来源:https://stackoverflow.com/questions/10417344/yet-another-issue-about-log4net-1-2-11-conflicts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!