国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

使用Common.Logging與log4net的組件版本兼容問題

2019-11-17 03:10:44
字體:
來源:轉載
供稿:網友

使用Common.Logging與log4net的組件版本兼容問題

近期使用了Common.Logging的ILog接口做日志接口,同時利用其log4net適配器與log4net記錄器來記錄系統日志,在使用過程中碰到了log4net版本問題。

項目組件管理中安裝組件包:

PM> Install-Package Common.Logging

PM> Install-Package Common.Logging.Log4Net 【2.0.1版本;依賴Common.Logging (≥ 2.0.0); log4net (= 1.2.10)】

項目中將引用log4net.dll版本為 1.2.10.0,在此配套版本情況下,運行出現錯誤: {"Unable to create type 'Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net'"}

也將log4net組件升級到最新版本1.2.13失敗,Install-Package : 將“log4net 1.2.10”更新到“log4net 2.0.3”失敗。找不到與“log4net 2.0.3”兼容的“Common.Logging.Log4Net”版本。

將Common.Logging.Log4Net版本刪除,重新安裝以下版本

PM> Install-Package Common.Logging.Log4Net1211 【2.2.0版本;Common.Logging (≥ 2.0.0);Log4Net (≥ 1.2.11)】

項目中log4net.dll版本為 1.2.11.0, 運行OK,升級log4net1.2.13版本,升級成功,運行OK;

注意配置文件中程序集文件名差異

  <common>    <logging>      <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net1211">

版本重定向

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">      <dependentAssembly>        <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" />        <bindingRedirect oldVersion="0.0.0.0-2.2.0.0" newVersion="2.2.0.0" />           </dependentAssembly>        <dependentAssembly>        <assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />        <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" />      </dependentAssembly>    </assemblyBinding>

原因主要是由于log4net version 1.2.11與1.2.10的publicKeyToken不同所致。可利用VS工具SN –T 組件文件名.dll查看公鑰。

log4net (≥ 1.2.11) 公鑰標記為 669e0ddf0bb1aa2a

log4net (= 1.2.10) 公鑰標記為 1b44e1d426115821

http://www.nuget.org/packages/Log4Net/

http://www.nuget.org/packages/Common.Logging/

http://www.nuget.org/packages/Common.Logging.Log4Net1211/

http://www.nuget.org/packages/Common.Logging.Log4Net/

http://developer.3l.nl/post/16463925249/log4net-1-2-11-dependency-hell

解決方式2,不同版本的publicKeyToken

<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"><dependentAssembly><assemblyIdentity name="log4net" publicKeyToken="681549d62126b7b8" /><codeBase version="1.2.9.0" href="bin/log4net1.2.9.0/log4net1.2.9.0.dll" /></dependentAssembly><dependentAssembly><assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" /><codeBase version="1.2.10.0" href="bin/log4net1.2.10.0/log4net1.2.10.0.dll" /></dependentAssembly><dependentAssembly><assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" /> <bindingRedirect oldVersion="0.0.0.0-1.2.13.0" newVersion="1.2.13.0" /> </dependentAssembly></assemblyBinding></runtime>
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 秀山| 阿克陶县| 元阳县| 普定县| 准格尔旗| 山丹县| 广德县| 邛崃市| 丹江口市| 南京市| 多伦县| 龙陵县| 东乡县| 玉门市| 拜城县| 西乌珠穆沁旗| 巍山| 关岭| 民丰县| 聂拉木县| 色达县| 微山县| 镇赉县| 塔城市| 保康县| 嘉兴市| 班玛县| 洛宁县| 巴楚县| 集安市| 平果县| 卢龙县| 涿州市| 丰原市| 沙田区| 房山区| 永登县| 沙雅县| 阿荣旗| 普格县| 灵武市|