PerformanceCounterCategory.Exists抛出'输入字符串的格式不正确。'

时间:2009-07-20 08:51:40

标签: 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, 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)

不想责怪框架:)我做错了什么?

编辑:检查效果对象列表后 - 它的数字而不是普通文本 - 看起来列表已损坏 - 要尝试this KB

1 个答案:

答案 0 :(得分:1)

确定。原来是一个非常腐败的注册表。要修复我从xp光盘获取(来自问题中的KB)perfc009.dat和perfh009.bat(请参阅this KB以扩展光盘) 并将它们弹出到%systemroot%/ system32中。

相关问题