PerformanceCounterCategory.Exists抛出“输入字符串的格式不正确." [英] PerformanceCounterCategory.Exists throwing 'Input string was not in a correct format.'

查看:136
本文介绍了PerformanceCounterCategory.Exists抛出“输入字符串的格式不正确."的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用来检查表演类别的存在时

When I'm checking for the existance of a performace category using

PerformanceCounterCategory.Exists("myCategory")

在不存在该类别的系统(全新安装的XP SP3)上,我抛出了以下异常...

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?

:在检查了性能对象"列表后-它充满了数字,而不是普通文本-列表似乎已损坏-尝试

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

推荐答案

好.原来是一个非常损坏的注册表.要修复,我(从问题的KB中)从xp光盘中获得了perfc009.dat和perfh009.bat(请参见此KB (用于扩展光盘) 并将它们弹出到%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.

这篇关于PerformanceCounterCategory.Exists抛出“输入字符串的格式不正确."的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆