【发布时间】:2011-10-29 06:27:35
【问题描述】:
当我的网络服务出现任何异常时,我一直在使用 log4Net 写入文本文件,这可以正常工作,但今天它开始抛出错误。
System.Web.Services.Protocols.SoapException: Server was unable to处理请求。 ---> System.TypeInitializationException:类型 .. 的初始化程序引发了异常。 ---> System.IO.FileLoadException:无法加载文件或程序集 'log4net,版本=1.2.9.0,文化=中性, PublicKeyToken=b32731d11ce58905' 或其依赖项之一。这 定位程序集的清单定义与程序集不匹配 参考。 (来自 HRESULT 的异常:0x80131040) 文件名:'log4net,版本=1.2.9.0,文化=中性, PublicKeyToken=b32731d11ce58905'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
如果您对此堆栈信息有任何输入,请。分享吧。
【问题讨论】:
-
看起来您的 log4net.dll 被覆盖了,可能版本不同。您能否验证您的 Web 服务使用的 log4net.dll 版本是否为 1.2.9.0?您还可以使用 Visual Studio 附带的 sn.exe 工具 (sn.exe -T log4net.dll) 检查 PublicKeyToken 是否匹配。
-
这是我得到的错误:log4net:Error XMLConfigurator:Failed to find configuration section 'log4net' in the applications's .config file。检查
和 的 .config 文件。配置部分应如下所示: 我检查了我的 web.config,这是正确的找我: -
等等,你运行的是正确的版本(1.2.9.0)吗?您是否尝试按照建议添加配置部分?
标签: c# asp.net web-services exception-handling log4net