所以我正在创建一些自定义性能计数器并将它们分组到一个类别下。它构建在IIS 7上托管并通过visual studio运行的WCF应用程序中。
我一直在关注msdn的示例和文档here
这是我在我的方法中使用的代码:
if (PerformanceCounterCategory.Exists("MyCategory"))
{
PerformanceCounterCategory.Delete("MyCategory");
}
CounterCreationDataCollection counters = new CounterCreationDataCollection();
CounterCreationData getRequests = new CounterCreationData();
getRequests.CounterName = "Get count per sec";
getRequests.CounterHelp = "Get count per sec";
getRequests.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
counters.Add(getRequests);
CounterCreationData headRequests = new CounterCreationData();
headRequests.CounterName = "Head count per sec";
headRequests.CounterHelp = "Head count per sec";
headRequests.CounterType = PerformanceCounterType.RateOfCountsPerSecond64;
counters.Add(headRequests);
PerformanceCounterCategory.Create("MyCategory", "Custom Category", PerformanceCounterCategoryType.SingleInstance,counters);
我遇到的问题是最后一行给了我一个例外
System.dll中出现未处理的“System.ComponentModel.Win32Exception”类型异常 附加信息:参数不正确
编辑:
调用堆栈如下所示:
System.Diagnostics.PerformanceCounterLib.RegisterFiles(字符串 arg0,布尔取消注册) 在System.Diagnostics.PerformanceCounterLib.RegisterCategory(String categoryName,PerformanceCounterCategoryType categoryType,String categoryHelp,CounterCreationDataCollection creationData) 在System.Diagnostics.PerformanceCounterCategory.Create(String categoryName,String categoryHelp,PerformanceCounterCategoryType categoryType,CounterCreationDataCollection counterData)
我想知道是否有人知道或已经看过这个问题?