Problem creating PerformanceCounter
-
Friday, April 20, 2007 3:30 PM
Hi.
I get this exception:
Unhandled Exception: System.FormatException: 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.Create(String categoryName, String categoryHelp, PerformanceCounterCategoryType categoryType, CounterCreationDataCollection counterData)
in this code:
try {
PerformanceCounterCategory.Delete("my category");
} catch {
}
CounterCreationDataCollection counterData = new CounterCreationDataCollection();
counterData.Add(new CounterCreationData("something", "something description", PerformanceCounterType.NumberOfItems64));
counterData.Add(new CounterCreationData("something else", "something else description", PerformanceCounterType.RateOfCountsPerSecond32));
PerformanceCounterCategory.Create("my category", "my category description", PerformanceCounterCategoryType.Unknown, counterData);I'm using .Net 2.0.
What am I doing wrong?
Best regards,
Gustavo Guerra
Answers
-
Thursday, April 26, 2007 11:34 PMModerator
The original problem is corrupt PerformanceCounter info on the machine you're trying to run. But, there's a bug in the PerformanceCounter code resulting in you getting the wrong exception. This bug will be fixed in a future version, however, at this point you would need to clean this machine's performancecounter information since its corrupt to get this working correctly. If you have another machine - try this code on that other machine to see that it's working there.
Inbar.
All Replies
-
Thursday, April 26, 2007 11:34 PMModerator
The original problem is corrupt PerformanceCounter info on the machine you're trying to run. But, there's a bug in the PerformanceCounter code resulting in you getting the wrong exception. This bug will be fixed in a future version, however, at this point you would need to clean this machine's performancecounter information since its corrupt to get this working correctly. If you have another machine - try this code on that other machine to see that it's working there.
Inbar.
-
Friday, April 27, 2007 8:51 AM
Will there be any Microsoft hotfix to fix the wrong exception?
How can the corrupt performance counters be cleaned-up and how can I find out how they have become corrupted?
Best Regards,
Gustavo Guerra
-
Friday, April 27, 2007 5:38 PMModerator
Cleaning the corrupt perf counters requires cleaning registry entries in the perf counter hive on this machine.
I'm not sure how to find out at this point why or how they became corrupt.
Inbar.

