我正在尝试从 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 上。
我尝试卸载它并重新安装,但没有成功,然后我尝试再次卸载并安装 IIS Express 7.5,它可以工作
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)