Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 性能计数器不工作_C#_Performancecounter_Ranorex - Fatal编程技术网

C# 性能计数器不工作

C# 性能计数器不工作,c#,performancecounter,ranorex,C#,Performancecounter,Ranorex,性能计数器在c#模式下不工作。我认为这是一个系统问题。因为,它在其他系统中运行良好。如何纠正?它显示以下代码的错误: 来自Ranorex工具的代码: string prcName = "chrome"; PerformanceCounter counter = new PerformanceCounter("Process", "Working Set - Private",prcName) Report.Info("MonAlbum memory", (counter.RawValue /

性能计数器在c#模式下不工作。我认为这是一个系统问题。因为,它在其他系统中运行良好。如何纠正?它显示以下代码的错误:

来自Ranorex工具的代码:

string prcName = "chrome";
PerformanceCounter counter = new PerformanceCounter("Process", "Working Set - Private",prcName)
Report.Info("MonAlbum  memory", (counter.RawValue / 1024).ToString("#,##0")+" KB");
错误:

找不到具有指定类名的性能计数器 “进程”计数器名称“工作集-专用”


您是否在旧操作系统版本下运行测试

如上所述,Windows Server 2003和Windows XP不支持进程/工作集-专用


这似乎有一个解决办法,但我从未尝试过。

谢谢分享您宝贵的想法。
实际问题是注册表已损坏。正因为如此,代码片段无法工作。重新安装操作系统刚刚解决了这个问题。

使用性能监视器检查计数器是否存在。安全权限问题?不同操作系统版本的计数器名称不同。此外,有时它们会损坏,将所有计数器都更改为数字。正如Schaliasos所说,使用perfmon查找它。正如cad所说,尝试在管理员权限下运行Visual Studio以排除安全问题。