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

求助:无法将NuGet包System.Diagnostics.DiagnosticSource从8.0.0升级至8.0.1

System.Diagnostics.DiagnosticSource程序集绑定重定向失效问题

我负责维护的项目一直使用System.Diagnostics.DiagnosticSource 8.0.0版本,由于部分依赖包未更新,仍依赖5.0.0版本,所以项目配置了程序集绑定重定向,让所有组件统一使用8.0.0版本,配置如下:

<dependentAssembly>
   <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
   <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>

近期我将NuGet包更新至最新版本(升级到8.0.1.0),其他包更新都正常,但这个包出现了运行时错误。

第一次错误场景

起初忘记更新绑定重定向,触发以下运行时异常:

System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

原本绑定重定向应该处理版本不匹配问题,但更新包后完全失效,既找不到8.0.0.0也找不到5.0.0.0版本。

尝试修复后仍报错

我随后更新了绑定重定向配置,改为指向8.0.1.0版本:

<dependentAssembly>
   <assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
   <bindingRedirect oldVersion="0.0.0.0-8.0.1.0" newVersion="8.0.1.0" />
</dependentAssembly>

但问题依旧,运行时仍抛出类似异常,提示找不到8.0.1.0或5.0.0.0版本:

System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=8.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) ---> System.IO.FileLoadException: Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

如果暂时没人能解决这个问题,我会在Stack Overflow允许后自行发布解决方案。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 17:30:58