简体   繁体   English

将System.Diagnostics替换为.Net Core 2.0(C#)

[英]Replace System.Diagnostics into .Net Core 2.0 (C#)

I got method in console app .net 4.6 : 我在控制台应用程序.net 4.6中获得了方法:

using System.Diagnostics;

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

When try to do it into class library .NET Core 2.0 I got problem: 尝试将其放入类库.NET Core 2.0时遇到问题:

  • the namespace doesn't exisit 命名空间不存在

What can I do now? 我现在能做什么?

You need package System.Diagnostics.PerformanceCounter. 您需要包System.Diagnostics.PerformanceCounter。 Install it using package manager or console 使用软件包管理器或控制台安装

Install-Package System.Diagnostics.PerformanceCounter -Version 4.5.0

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM