tags:

views:

486

answers:

1

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

+1  A: 

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.

PaulB
This manafested itself when using PolyMon on a Windows 2003 server, doing the same (from an W2K3 Disc) worked in my case, without apparant side effects. Thanks.
Richard Slater