Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.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#_Asp.net Mvc_Windows_C# 4.0_Performancecounter - Fatal编程技术网

C# 添加性能计数器类别挂起计算机

C# 添加性能计数器类别挂起计算机,c#,asp.net-mvc,windows,c#-4.0,performancecounter,C#,Asp.net Mvc,Windows,C# 4.0,Performancecounter,我正在尝试从ASP.NET MVC应用程序(Windows 8 x64 PC上的VS 2012)添加性能计数器,但我遇到的问题是,如果我检查类别是否存在或添加新的性能计数器类别,计算机将挂起 我的代码是: namespace TestMvcCounter { public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() {

我正在尝试从ASP.NET MVC应用程序(Windows 8 x64 PC上的VS 2012)添加性能计数器,但我遇到的问题是,如果我检查类别是否存在或添加新的性能计数器类别,计算机将挂起

我的代码是:

namespace TestMvcCounter
{
  public class MvcApplication : System.Web.HttpApplication
  {
      protected void Application_Start()
      {
          AreaRegistration.RegisterAllAreas();

          WebApiConfig.Register(GlobalConfiguration.Configuration);
          FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
          RouteConfig.RegisterRoutes(RouteTable.Routes);
          BundleConfig.RegisterBundles(BundleTable.Bundles);

          if (!PerformanceCounterCategory.Exists("MY_TEST"))
          {
              CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
              ccdc.Add(new CounterCreationData() { CounterName = "# loops", CounterType = PerformanceCounterType.RateOfCountsPerSecond32 });

              PerformanceCounterCategory.Create("MY_TEST", "Test performance counter", PerformanceCounterCategoryType.MultiInstance, ccdc);
          }

      }
   }
}
当代码到达这一行时

!PerformanceCounterCategory.Exists("MY_TEST")
系统挂起,没有任何异常或超时


你知道是什么导致了这个问题吗?

经过深入搜索,我发现问题出在IIS Express 8上


我尝试unistall并重新安装,但没有成功,然后我再次尝试unistall并安装IIS Express 7.5,结果正常

您能提供更多详细信息吗?我可能也有同样的问题,但对于VisualStudio 2015和IISExpress 10,我们在VS 2019上面临着完全相同的问题。我尝试卸载并安装不同版本的IIS Express,但未成功。