C# PerformanceCounterCategory。使用参数创建中断不正确
因此,我创建了两个自定义性能计数器,并将它们归为一个类别。这是在承载在IIS 7上并通过visual studio运行的WCF应用程序中构建的 我一直在遵循msdn的示例和文档 下面是我在方法中使用的代码:C# PerformanceCounterCategory。使用参数创建中断不正确,c#,wcf,performancecounter,C#,Wcf,Performancecounter,因此,我创建了两个自定义性能计数器,并将它们归为一个类别。这是在承载在IIS 7上并通过visual studio运行的WCF应用程序中构建的 我一直在遵循msdn的示例和文档 下面是我在方法中使用的代码: if (PerformanceCounterCategory.Exists("MyCategory")) { PerformanceCounterCategory.Delete("MyCategory"); } CounterCreationDataCollection count
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.RegisterFile(字符串
arg0,布尔值(取消注册)
在System.Diagnostics.PerformanceCounterLib.RegisterCategory(字符串
categoryName,PerformanceCounterCategoryType类别类型,字符串
类别帮助、反创建数据集合(创建数据)
在System.Diagnostics.PerformanceCounterCategory.Create(字符串
categoryName、字符串categoryHelp、PerformanceCounterCategoryType
类别类型、计数器创建数据收集计数器数据)
我想知道是否有人知道或见过这个问题 你有管理员权限吗?我想你需要他们来创建类别:(我没有管理员权限。你可能认为异常处理程序会返回UnauthorizedAccessException,而不是像“参数不正确”这样奇怪的东西)…不知道,抱歉。请在您正在管理的pc上尝试此功能以进行检查。可能是的,它会。您可以使用Win32异常详细信息更新您的帖子吗?您指的是什么类型的其他详细信息?我已经将调用堆栈附加到帖子上,但所有输出窗口都是我上面列出的内容。