【问题标题】:Replace System.Diagnostics into .Net Core 2.0 (C#)将 System.Diagnostics 替换为 .Net Core 2.0 (C#)
【发布时间】:2019-12-03 14:52:09
【问题描述】:

我在 console app .net 4.6 中获得了方法:

using System.Diagnostics;

public static void CPUMonitorTest()
{
   var cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
   ...
}

当尝试在 类库 .NET Core 2.0 中执行此操作时,我遇到了问题:

  • 命名空间不存在

我现在能做什么?

【问题讨论】:

标签: c# .net .net-core system.diagnostics


【解决方案1】:

您需要软件包 System.Diagnostics.PerformanceCounter。使用包管理器或控制台安装它

Install-Package System.Diagnostics.PerformanceCounter -Version 4.5.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    • 1970-01-01
    • 1970-01-01
    • 2018-12-08
    • 2018-08-06
    • 1970-01-01
    相关资源
    最近更新 更多