Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.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# ASP.NET性能计数器值_C#_Asp.net_.net_Performancecounter - Fatal编程技术网

C# ASP.NET性能计数器值

C# ASP.NET性能计数器值,c#,asp.net,.net,performancecounter,C#,Asp.net,.net,Performancecounter,我正在构建一个库项目,当与ASP.NET项目一起使用时,它将记录ASP.NET性能计数器的值。但当我尝试运行以下代码时- var _RequestsPerSecond = new PerformanceCounter("ASP.NET Applications", "Requests/sec", Process.GetCurrentProcess().ProcessName); _RequestsInApplicationQueueValue = _RequestsInApplication

我正在构建一个库项目,当与ASP.NET项目一起使用时,它将记录ASP.NET性能计数器的值。但当我尝试运行以下代码时-

var  _RequestsPerSecond = new PerformanceCounter("ASP.NET Applications",  "Requests/sec", Process.GetCurrentProcess().ProcessName);
_RequestsInApplicationQueueValue = _RequestsInApplicationQueue.NextValue();

它给我的错误是iis express在此类别中不存在。有什么建议吗?

替换Process.GetCurrentProcess().ProcessName为System.Web.Hosting.HostingEnvironment.ApplicationID.replace('/',''.')

我必须在我的库中为System.Web添加一个依赖项才能做到这一点。是否有任何方法可以在不添加任何依赖项的情况下执行此操作。?可能是您可以引用此博客以按进程id获取实例名称:这对ASP.NET应用程序性能计数器很好,但对ASP.NET计数器再次抛出错误。