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

.NET 6应用报错:无法加载System.Diagnostics.PerformanceCounter程序集

.NET Core 6 应用加载 System.Diagnostics.PerformanceCounter 失败问题

异常信息

未处理异常。System.IO.FileNotFoundException: 无法加载文件或程序集“System.Diagnostics.PerformanceCounter, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51”。系统找不到指定的文件。

已尝试操作

已添加如下包引用,但问题仍未解决:

<PackageReference Include="System.Diagnostics.PerformanceCounter" VersionOverride="8.0.0" />

解决方案

  • 匹配版本兼容性:.NET Core 6 与8.0.0版本的System.Diagnostics.PerformanceCounter存在兼容问题,建议降级包版本到与.NET Core 6对应的稳定版本(如6.0.x)。
  • 修正引用属性:VersionOverride不是标准的NuGet引用属性,应改为Version,正确的引用格式如下:
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="6.0.0" />
  • 清理重建项目:运行dotnet clean清理项目缓存,执行dotnet restore重新还原依赖,再重建项目。
  • 检查运行环境:System.Diagnostics.PerformanceCounter仅支持Windows系统,若在Linux/macOS环境运行,需移除该依赖或更换为跨平台性能监控方案。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 13:05:53