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

构建.NET项目遇Microsoft Practices EnterpriseLibrary Common版本冲突求解决

解决EnterpriseLibrary Common版本冲突问题

1. 排查间接依赖来源

  • 打开Visual Studio的解决方案资源管理器,右键点击解决方案选择「管理解决方案的NuGet程序包」,切换到「已安装」标签,检查所有项目的依赖包,确认是否有第三方组件或其他NuGet包引用了4.1.0.0版本的EnterpriseLibrary Common。
  • 也可以在解决方案根目录的命令行中执行dotnet list package --include-transitive命令,查看所有间接依赖的包版本,定位到引用4.1.0.0版本的来源。

2. 添加/修正程序集绑定重定向

  • 打开项目的App.config或Web.config文件,在<configuration>节点下添加绑定重定向配置,强制所有版本的该程序集指向5.0.414.0:
<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="Microsoft.Practices.EnterpriseLibrary.Common"
                        publicKeyToken="xxxxxxxxxxxx"
                        culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-5.0.414.0"
                       newVersion="5.0.414.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>
  • 注意替换publicKeyToken为提示中的实际值;如果已有绑定重定向,检查oldVersion范围是否包含4.1.0.0,newVersion是否正确设置为5.0.414.0。

3. 清理编译缓存

  • 右键点击解决方案,依次选择「清理解决方案」→「生成解决方案」,清除旧编译文件。
  • 手动删除每个项目下的bin和obj目录,避免残留旧版本程序集干扰。

4. 检查全局程序集缓存(GAC)

  • 以管理员身份打开命令提示符,执行gacutil /l Microsoft.Practices.EnterpriseLibrary.Common,查看GAC中是否存在4.1.0.0版本的程序集。
  • 若存在,执行gacutil /u Microsoft.Practices.EnterpriseLibrary.Common,Version=4.1.0.0,Culture=neutral,PublicKeyToken=xxxxxxxxxxxx卸载该版本(替换对应参数)。

5. 确认项目引用属性

  • 右键点击引用了EnterpriseLibrary Common的项目,选择「引用」,找到Microsoft.Practices.EnterpriseLibrary.Common并查看属性:确认版本为5.0.414.0,复制本地设置为True,确保编译时正确版本的程序集会被复制到输出目录。

内容的提问来源于stack exchange,提问作者My Point Of View

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.18 23:05:24