【问题标题】:Add Performance Counter Category Hangs Computers添加性能计数器类别挂起计算机
【发布时间】:2013-04-24 14:07:37
【问题描述】:

我正在尝试从 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")

系统挂起,没有任何异常或超时

您知道导致问题的原因是什么吗?

【问题讨论】:

    标签: c# asp.net-mvc windows c#-4.0 performancecounter


    【解决方案1】:

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

    我尝试卸载它并重新安装,但没有成功,然后我尝试再次卸载并安装 IIS Express 7.5,它可以工作

    【讨论】:

    • 你能提供更多细节吗?我可能有同样的问题,但使用 VisualStudio 2015 和 IISExpress 10。
    • 我们在 VS 2019 上遇到了完全相同的问题。我尝试卸载和安装不同版本的 IIS Express,但均未成功。
    猜你喜欢
    • 2010-11-10
    • 1970-01-01
    • 2010-09-13
    • 2023-03-14
    • 1970-01-01
    • 1970-01-01
    • 2011-12-31
    • 1970-01-01
    • 2011-03-18
    相关资源
    最近更新 更多