问题
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