You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 4.8项目中不同组件依赖不同版本Common.Logging的冲突解决咨询

依赖冲突解决方案

能否同时使用两个版本的Common.Logging?

可以实现,具体步骤如下:

  • 同时安装Common.Logging 1.2.0及满足Quartz要求的新版本(如2.1.2)到项目中
  • 找到Common.Logging 1.2.0的程序集文件,重命名为Common.Logging.v1.2.0.dll(避免与新版本文件重名)
  • 将重命名后的文件添加到项目中,设置其「复制到输出目录」属性为「始终复制」
  • 在项目的app.config或web.config中配置程序集绑定规则:
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <!-- 指定遗留dll使用旧版本 -->
    <dependentAssembly>
      <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral"/>
      <codeBase version="1.2.0.0" href="Common.Logging.v1.2.0.dll"/>
    </dependentAssembly>
    <!-- 指定Quartz及其他组件使用新版本 -->
    <dependentAssembly>
      <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-[你的新版本号]" newVersion="[你的新版本号]"/>
    </dependentAssembly>
  </assemblyBinding>
</runtime>

注意:需确认Common.Logging的公钥Token是否正确,可通过反编译工具查看程序集信息。

其他标准解决方案

  • 隔离遗留组件:把遗留dll封装到独立的类库项目中,该项目仅引用Common.Logging 1.2.0,主项目通过进程间通信(如WCF、HTTP接口)或AppDomain隔离的方式调用这个类库,彻底分隔依赖环境
  • 替换Quartz日志依赖:若使用的Quartz版本支持,通过日志适配扩展将Quartz的日志输出切换到不依赖Common.Logging的框架(如log4net、NLog),从根源避免版本冲突
  • 隐藏警告:如果当前运行无异常,可在项目属性的「警告设置」中,将Common.Logging版本不匹配的警告编号(如MSB3277)设为「无」,但这只是临时隐藏警告,未解决依赖问题

内容的提问来源于stack exchange,提问作者James654987

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 15:31:12