性能计数器在 c# 中不工作。我认为这是一个系统问题。因为,它在其他系统中运行良好。如何纠正?它显示以下代码的错误:
来自 Ranorex 工具的代码:
string prcName = "chrome";
PerformanceCounter counter = new PerformanceCounter("Process", "Working Set - Private",prcName)
Report.Info("MonAlbum memory", (counter.RawValue / 1024).ToString("#,##0")+" KB");
错误:
Can not find the performance counter with the specified classname 'Process' countername 'Working Set - Private'
最佳答案
您是否在旧操作系统版本下运行测试?
如前所述here , Process/Working Set - Private 在 Windows Server 2003 和 Windows XP 下不受支持。
好像有解决办法here , 但我从未尝试过。
关于c# - 性能计数器不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15942264/