Exception occurs when trying to access "System\System Up Time" performancecounter in .NET (on XPe)

  • Thread starter =?ISO-8859-1?Q?=D8ivind_Berentsen?=
  • Start date
?

=?ISO-8859-1?Q?=D8ivind_Berentsen?=

Hi,

I'm experiencing some trouble when trying to access the "System\System
Up Time" performance counter. I used the following code:

PerformanceCounter pc = new PerformanceCounter("System", "System Up
Time", true);
pc.NextValue();
float seconds = pc.NextValue();

The code works perfectly on my development PC, running Windows XP SP2.

My XP embedded image is also SP2 and I've included the Performance
Counter Configuration component and resolved all dependencies.
I get the following exception information when trying to execute the code:

Unhandled Exception: System.TypeInitializationException: The type
initializer for "MPM.Common.TickClock" threw an except
ion. ---> System.InvalidOperationException: Category does not exist.
at System.Diagnostics.PerformanceCounterLib.CounterExists(String
machine, String category, String counter)
at System.Diagnostics.PerformanceCounter.Initialize()
at System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName, String instanceName, Boolean
readOnly)
at System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName, Boolean readOnly)
at MPM.Common.TickClock..ctor() in
d:\software\common\common\tickclock.cs:line 22
at MPM.Common.TickClock..cctor() in
d:\software\common\common\tickclock.cs:line 18
--- End of inner exception stack trace ---

I've successfully connected to the XPe computer with the System Monitor
from my development PC.

If anyone has any information on how to get the "System Up Time" counter
working, or can point me in the right direction it would be much
appreciated!

Cheers,
Øivind Berentsen
 
A

Adora Belle Dearheart

Øivind Berentsen said:
Hi,

I'm experiencing some trouble when trying to access the "System\System
Up Time" performance counter. I used the following code:

PerformanceCounter pc = new PerformanceCounter("System", "System Up
Time", true);
pc.NextValue();
float seconds = pc.NextValue();

The code works perfectly on my development PC, running Windows XP SP2.

My XP embedded image is also SP2 and I've included the Performance
Counter Configuration component and resolved all dependencies.
I get the following exception information when trying to execute the code:

Unhandled Exception: System.TypeInitializationException: The type
initializer for "MPM.Common.TickClock" threw an except
ion. ---> System.InvalidOperationException: Category does not exist.
at System.Diagnostics.PerformanceCounterLib.CounterExists(String
machine, String category, String counter)
at System.Diagnostics.PerformanceCounter.Initialize()
at System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName, String instanceName, Boolean
readOnly)
at System.Diagnostics.PerformanceCounter..ctor(String categoryName,
String counterName, Boolean readOnly)
at MPM.Common.TickClock..ctor() in
d:\software\common\common\tickclock.cs:line 22
at MPM.Common.TickClock..cctor() in
d:\software\common\common\tickclock.cs:line 18
--- End of inner exception stack trace ---

I've successfully connected to the XPe computer with the System Monitor
from my development PC.

If anyone has any information on how to get the "System Up Time" counter
working, or can point me in the right direction it would be much
appreciated!

Cheers,
Øivind Berentsen
Have you tried using the sysinternals tools to try to find out what
exactly it's trying to access that it hasn't got?
 
?

=?ISO-8859-1?Q?=D8ivind_Berentsen?=

Adora said:
Have you tried using the sysinternals tools to try to find out what
exactly it's trying to access that it hasn't got?

I've used filemon and regmon in order to track down what might be
missing. There was quite a bit information logged, even after I excluded
explorer.exe, regmon.exe and filemon.exe.

Is there another sysinternals tool you'd recommend or do you have some
hint as to what I should look for?

Sadly, I'm a real novice when i comes to performance counters. Is there
some files/registry settings that need to be there?

Any help would be appreciated :-D

Øivind
 
?

=?ISO-8859-1?Q?=D8ivind_Berentsen?=

Adora said:
Have you tried using the sysinternals tools to try to find out what
exactly it's trying to access that it hasn't got?

I also found that the "Counter" and "Help" values in the key
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009] Contains "System" and "System Up Time" as
shown below.

From the "Counter" value:
2
System
674
System Up Time

From the "Help" value:
3
The System performance object consists of counters that apply to more
than one instance of a component processors on the computer.
675
System Up Time is the elapsed time (in seconds) that the computer has
been running since it was last started. This counter displays the
difference between the start time and the current time.

Could this be a problem with the .NET configuration? I've included two
log that appeared in the folder windows\system32\log in case it's relevant.

The eventlog does not contain any information about the performance
counters. Only an item regarding the exception.

(Tue Feb 14 14:01:09 2006.879244) : NTLMLogin resulted in hr = 0x8004100e
(Tue Feb 14 14:13:46 2006.1635591) : NTLMLogin resulted in hr = 0x8004100e

(Tue Feb 14 14:01:10 2006.879514) : ESS unable to load consumer provider NTEventLogEventConsumer from provider subsystem: 0x80041013
(Tue Feb 14 14:01:10 2006.879514) : Failed the first attempt to retrieve the sink to deliver an event to event consumer NTEventLogEventConsumer="SCM Event Log Consumer" with error code 80041013.
WMI will reload and retry.
(Tue Feb 14 14:01:10 2006.879574) : ESS unable to load consumer provider NTEventLogEventConsumer from provider subsystem: 0x80041013
(Tue Feb 14 14:01:10 2006.879574) : Failed the second attempt to deliver an event to event consumer NTEventLogEventConsumer="SCM Event Log Consumer" with error code 80041013.
This event is dropped for this consumer.
(Tue Feb 14 14:01:10 2006.879574) : Dropping event destined for event consumer NTEventLogEventConsumer="SCM Event Log Consumer" in namespace //./root/subscription
(Tue Feb 14 14:01:10 2006.879574) : Dropping event destined for event consumer NTEventLogEventConsumer="SCM Event Log Consumer" in namespace //./root/subscription
(Tue Feb 14 14:01:10 2006.879634) : ESS unable to load consumer provider NTEventLogEventConsumer from provider subsystem: 0x80041013
(Tue Feb 14 14:01:10 2006.879634) : Failed the first attempt to retrieve the sink to deliver an event to event consumer NTEventLogEventConsumer="SCM Event Log Consumer" with error code 80041013.
WMI will reload and retry.
(Tue Feb 14 14:01:10 2006.879704) : ESS unable to load consumer provider NTEventLogEventConsumer from provider subsystem: 0x80041013
(Tue Feb 14 14:01:10 2006.879704) : Failed the second attempt to deliver an event to event consumer NTEventLogEventConsumer="SCM Event Log Consumer" with error code 80041013.
This event is dropped for this consumer.
(Tue Feb 14 14:01:10 2006.879704) : Dropping event destined for event consumer NTEventLogEventConsumer="SCM Event Log Consumer" in namespace //./root/subscription
(Tue Feb 14 14:13:46 2006.1635661) : ESS unable to load consumer provider NTEventLogEventConsumer from provider subsystem: 0x80041013
(Tue Feb 14 14:13:46 2006.1635661) : Failed the first attempt to retrieve the sink to deliver an event to event consumer NTEventLogEventConsumer="SCM Event Log Consumer" with error code 80041013.
WMI will reload and retry.
(Tue Feb 14 14:13:46 2006.1635742) : ESS unable to load consumer provider NTEventLogEventConsumer from provider subsystem: 0x80041013
(Tue Feb 14 14:13:46 2006.1635742) : Failed the second attempt to deliver an event to event consumer NTEventLogEventConsumer="SCM Event Log Consumer" with error code 80041013.
This event is dropped for this consumer.
(Tue Feb 14 14:13:46 2006.1635742) : Dropping event destined for event consumer NTEventLogEventConsumer="SCM Event Log Consumer" in namespace //./root/subscription
(Tue Feb 14 14:13:46 2006.1635772) : Dropping event destined for event consumer NTEventLogEventConsumer="SCM Event Log Consumer" in namespace //./root/subscription
(Tue Feb 14 14:13:46 2006.1635772) : Dropping event destined for event consumer NTEventLogEventConsumer="SCM Event Log Consumer" in namespace //./root/subscription
 
G

Guest

The perf counter libraries values are stored in the "Counter" registry value
located under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009. This "Counter" registry value is missing on
XPe. You could either just export the above registry branch on a working XP
Pro machine (preferrably fresh installation of XP) into a .reg file and then
import the file into an XPe machine. The reg file can also be componentized
or added to the configuration as an extra registry resources at build time.
Other suggestions where to delete Perflib\009 in the Performance Counter
Configuration component prior to build and let the runtime re-build it again.

Also, some perf counters have dependency on the existense of a pagefile. The
dependency on the pagefile has been removed in an XP QFE: See
http://support.microsoft.com/default.aspx?scid=kb;en-us;884558

KS

This posting is provided "AS IS" with no warranties and confers no rights.


Øivind Berentsen said:
Adora said:
Have you tried using the sysinternals tools to try to find out what
exactly it's trying to access that it hasn't got?

I also found that the "Counter" and "Help" values in the key
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009] Contains "System" and "System Up Time" as
shown below.

From the "Counter" value:
2
System
674
System Up Time

From the "Help" value:
3
The System performance object consists of counters that apply to more
than one instance of a component processors on the computer.
675
System Up Time is the elapsed time (in seconds) that the computer has
been running since it was last started. This counter displays the
difference between the start time and the current time.

Could this be a problem with the .NET configuration? I've included two
log that appeared in the folder windows\system32\log in case it's relevant.

The eventlog does not contain any information about the performance
counters. Only an item regarding the exception
 
G

Guest

K said:
The perf counter libraries values are stored in the "Counter" registry value
located under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009. This "Counter" registry value is missing on
XPe. You could either just export the above registry branch on a working XP
Pro machine (preferrably fresh installation of XP) into a .reg file and then
import the file into an XPe machine. The reg file can also be componentized
or added to the configuration as an extra registry resources at build time.
Other suggestions where to delete Perflib\009 in the Performance Counter
Configuration component prior to build and let the runtime re-build it again.

Also, some perf counters have dependency on the existense of a pagefile. The
dependency on the pagefile has been removed in an XP QFE: See
http://support.microsoft.com/default.aspx?scid=kb;en-us;884558

KS

This posting is provided "AS IS" with no warranties and confers no rights.

Thank you very much! It boils down to having an image with no pagefile,
I'm trying to get hold of the hotifx for this problem to see if it
enables the perf. counter.
Again, thanks a lot!

Regards,
Øivind
 

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