PerformanceCounterCategory.Exists 抛出“输入字符串的格式不正确。”
类别的系统(全新安装 XP SP3)上检查是否存在性能
PerformanceCounterCategory.Exists("myCategory")
当我在不存在该
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)
类别时,我会抛出以下异常......不想责怪框架:)什么我做错了吗?
编辑:检查性能对象列表后 - 它充满了数字而不是普通文本 - 看起来列表已损坏 - 将尝试 此知识库
When I'm checking for the existance of a performace category using
PerformanceCounterCategory.Exists("myCategory")
on a system (clean install of XP SP3) where the category doesn't exist I'm getting the following exception thrown ...
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)
Not wanting to blame the framework :) what am I doing wrong?
EDIT: After checking the Performance Object list - it's full of numbers rather than the normal text - looks like the list is corrupt - going to try this KB
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。 结果发现这是一个非常损坏的注册表。 为了解决这个问题,我从 xp 光盘中获取了(从问题中的知识库)perfc009.dat 和 perfh009.bat(请参阅 此知识库用于扩展光盘)
并将它们弹出到%systemroot%/system32中。
Ok. Turned out to be a very corrupt registry. To fix I got (from the KB in the question) perfc009.dat and perfh009.bat from the xp disc (see this KB for expanding off the disc)
and popped them into %systemroot%/system32.