Unable to Access Performance Counters Programmatically

A

Atmy Witsend

My C# application is unable to access any of the Performance Counters
when running under XP Embedded. Whenever I try to initialize a new
instance of any Performance Counter, my application throws the
following exception:

System.InvalidOperationException: Category does not exist.

If I make a call to the PerformanceCounterCategory.GetCategories()
method, an Array containing zero elements is returned (no Performance
Counter Categories exist).

The application does not have any problem when I run it on my Desktop
PC under XP Professional. I am able to run the perfmon utility on the
XP Embedded system and from there I see the usual categories and
counters. I have the following related components included in my XP
Embedded image:

Base Performance Counters
Disk Performance Counters
Network Performance Counters
Performance Counter Configuration

I noticed that there is a 'Performance Counter WMI Provider' component
that is available but it is not included in my XP Embedded image
because, based on the description of that component, it does not seem
to be necessary for the technique that I am using.

Am I missing some component(s) or is there maybe some kind of
permission setting that is not correct in the XP Embedded image? Any
help on this would be greatly appreciated.
 
G

Gordon Smith \(eMVP\)

Do you have a pagefile in your build? Without a pagefile, you'll be missing
a few of the categories (system, processor, memory, cache, etc.)

--Gordon Smith (eMVP)
 
A

Atmy Witsend

Gordon Smith \(eMVP\) said:
Do you have a pagefile in your build? Without a pagefile, you'll be missing
a few of the categories (system, processor, memory, cache, etc.)

--Gordon Smith (eMVP)

Yes, I do have a pagefile in my build. I am able to run the perfmon
utility on the XP Embedded system and from there I see the usual
categories and counters including the categories that you mention
(system, processor, memory, cache). I am not missing just a few of
the categories. It seems that I am missing all categories because
when I make a call to the C#
PerformanceCounterCategory.GetCategories() method, an Array containing
zero elements is returned (no Performance Counter Categories exist).
 
H

H.R.

Same Problem with the performance Counter here.
All Suggestions
Add a pagefile,
Search for registry key DWORD value "Disable Performance Counters"
rebuild counters with loadctr.exe and so on, gave no success.

The problem is posted quite a few times here,
where is the step by step solution from Microsoft ?

Regards H.R.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top