C# PerformanceCounterCategory.com';输入字符串的格式不正确;

C# PerformanceCounterCategory.com';输入字符串的格式不正确;,c#,perfmon,C#,Perfmon,当我使用 PerformanceCounterCategory.Exists("myCategory") 在一个类别不存在的系统(XP SP3的干净安装)上,我将抛出以下异常 Input string was not in a correct format. at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info,

当我使用

PerformanceCounterCategory.Exists("myCategory")
在一个类别不存在的系统(XP SP3的干净安装)上,我将抛出以下异常

    Input string was not in a correct format.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
       at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
       at System.Int32.Parse(String s, IFormatProvider provider)
       at System.Diagnostics.PerformanceCounterLib.GetStringTable(Boolean isHelp)
       at System.Diagnostics.PerformanceCounterLib.get_NameTable()
       at System.Diagnostics.PerformanceCounterLib.get_CategoryTable()
       at System.Diagnostics.PerformanceCounterLib.CategoryExists(String machine, String category)
       at System.Diagnostics.PerformanceCounterCategory.Exists(String categoryName, String machineName)
       at System.Diagnostics.PerformanceCounterCategory.Exists(String categoryName)
不想责怪框架:)我做错了什么


编辑:检查性能对象列表后-列表中充满了数字而不是普通文本-列表似乎已损坏-将尝试确定。结果是一个非常腐败的注册表。要修复我从xp光盘(请参阅光盘扩展部分)获得的perfc009.dat和perfh009.bat(来自问题中的KB)
并将它们弹出到%systemroot%/system32中

当在Windows2003服务器上使用PolyMon时,这一点得到了有效的管理,在我的情况下(从W2K3光盘上)也是如此,没有明显的副作用。谢谢。您也可以从命令提示符下运行
Lodctr.exe/r
(来源:)