Add Performance Counter Category Hangs Computers

不问归期 提交于 2020-01-15 07:36:07

问题


I am trying from a ASP.NET MVC Application (with VS 2012 on Windows 8 x64 PC) to add a Perfomance Counter but I have the problem that if I check the category exists or add a new Performance Counter Category the computer hangs

My code is:

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);
          }

      }
   }
}

and when the code reach this line

!PerformanceCounterCategory.Exists("MY_TEST")

the system hangs without any exception or timeout

Do you know what could be that cause the issue?


回答1:


After a deep search I figured out the problem was IIS Express 8.

I tried to unistall it and re-install but didn't work, then I tried to unistall again and install the IIS Express 7.5 and it works



来源:https://stackoverflow.com/questions/16194163/add-performance-counter-category-hangs-computers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!