Bug 7323 - System.Diagnostics.PerformanceCounterCategory Exception while accessing user defined performanceCounters
Summary: System.Diagnostics.PerformanceCounterCategory Exception while accessing user ...
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-09-20 05:54 UTC by Herwig
Modified: 2012-09-20 05:55 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

source code and sample output of execution in windows and linux (6.76 KB, application/zip)
2012-09-20 05:54 UTC, Herwig

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 7323 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Herwig 2012-09-20 05:54:57 UTC
Created attachment 2578 [details]
source code and sample output of execution in windows and linux

I wrote a code that lists all performanceCounters for a specific category and displays their results.

This works fine for all pre-defined PerformanceCounterCategories.
With user-defined counter categories, this does not work.

In the attachment you find a modified version of the code from:

(Here you can also see the bug that was reported with ID 7322, I wrote two reports as I think that they are different)

part of code:
SetupCategory(categoryName);  //creates a new category
CreateCounters(categoryName); //creates counters for the new category
CollectSamples(samplesList);  //stores values to the counters
CalculateResults(samplesList);  //calculates results - bug-id7322
printCountersForCategory(categoryName);  //see description 1
printCountersForCategoryPerNames(categoryName, new string[]{"AverageCounter64Sample", "AverageCounter64SampleBase"});

The two methods "printCountersForCategory" and "printCountersForCategoryPerNames"
both try to print all counters for a specific category.  In the first case, the Method
PerformanceCounterCategory.GetCounters(...) is used.  This throws an exception in (I guess line 109 of https://github.com/mono/mono/blob/fe8bdbcef723fc8c92afcc822aa4c12e34c21c0b/mcs/class/System/System.Diagnostics/PerformanceCounter.cs)
This problem seams to be caused by (I guess line 256 of https://github.com/mono/mono/blob/fe8bdbcef723fc8c92afcc822aa4c12e34c21c0b/mcs/class/System/System.Diagnostics/PerformanceCounterCategory.cs).
The method GetCounterNames seams to return at least one value "" -> which then throws the exception as described above.

If the names are known, the performanceCounters can be accessed as wished (showed in "printCountersForCategoryPerNames").

by the way, PerformanceCounter.RemoveInstance throws an notImplementedException. It would be good if at least the comment could state why this method is not important or why it is not implemented yet.