XPe - Process.GetProcessesByName - InvalidOperationException

G

Guest

We are receiving the following error on XP Embedded only
when calling the C#
System.Diagnostics.Process.GetProcessesByName method:

D:\_WTA>calc_test_process.exe
System.InvalidOperationException: Process performance
counter is disabled, so th
e requested operation cannot be performed.
at System.Diagnostics.NtProcessManager.GetProcessInfos
(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos
(String machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos
(String machineName)
at System.Diagnostics.Process.GetProcessesByName(String
processName, String m
achineName)
at System.Diagnostics.Process.GetProcessesByName(String
processName)
at Calc_Test_Process.Class1.Main(String[] args)


This is using a small test program recommended by a
previous post:

try
{
Process [] localByName =
Process.GetProcessesByName("calc");
Console.WriteLine
(localByName.Length);
}
catch(Exception ex)
{
Console.WriteLine
(ex.ToString());
}

The code works fine on Windows 2000 / NT Manager
Workstation. Running Performance Monitor shows the
counters ok, and searching the registry for: "Disable
Performance Counters" set to 1 yields no results.

Any idea?

Thanks,
Burkhard
SQA Tester
 
P

Phil Wilson

Not sure if this helps, but the explanation is that this Process class
method uses the performance counters to get the process list, and on that
XPe system the counters are disabled. XPe systems are typically built by
picking components to include in the OS. XPe doesn't necessarily have the
same features as XP. If this is your XPe, you might be able to create the
image to include the performance counters (ask in the XP embedded group).
Otherwise the only thing I can think of is use the Win32 APIs.
 
B

Burkhard

Thanks for the reply, Phil.

Which Win32 API call would you use?


Thanks,
Burkhard
-----Original Message-----
Not sure if this helps, but the explanation is that this Process class
method uses the performance counters to get the process list, and on that
XPe system the counters are disabled. XPe systems are typically built by
picking components to include in the OS. XPe doesn't necessarily have the
same features as XP. If this is your XPe, you might be able to create the
image to include the performance counters (ask in the XP embedded group).
Otherwise the only thing I can think of is use the Win32 APIs.
--
Phil Wilson [MVP Windows Installer]
----
We are receiving the following error on XP Embedded only
when calling the C#
System.Diagnostics.Process.GetProcessesByName method:

D:\_WTA>calc_test_process.exe
System.InvalidOperationException: Process performance
counter is disabled, so th
e requested operation cannot be performed.
at System.Diagnostics.NtProcessManager.GetProcessInfos
(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos
(String machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos
(String machineName)
at System.Diagnostics.Process.GetProcessesByName (String
processName, String m
achineName)
at System.Diagnostics.Process.GetProcessesByName (String
processName)
at Calc_Test_Process.Class1.Main(String[] args)


This is using a small test program recommended by a
previous post:

try
{
Process [] localByName =
Process.GetProcessesByName("calc");
Console.WriteLine
(localByName.Length);
}
catch(Exception ex)
{
Console.WriteLine
(ex.ToString());
}

The code works fine on Windows 2000 / NT Manager
Workstation. Running Performance Monitor shows the
counters ok, and searching the registry for: "Disable
Performance Counters" set to 1 yields no results.

Any idea?

Thanks,
Burkhard
SQA Tester


.
 
G

Guest

WORKAROUND: DELETE the "\009" registry subkey under:
[HKLM\SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Perflib\009]. This is supposed to be
fixed by XPe SP2.

Burkhard


-----Original Message-----
Thanks for the reply, Phil.

Which Win32 API call would you use?


Thanks,
Burkhard
-----Original Message-----
Not sure if this helps, but the explanation is that this Process class
method uses the performance counters to get the process list, and on that
XPe system the counters are disabled. XPe systems are typically built by
picking components to include in the OS. XPe doesn't necessarily have the
same features as XP. If this is your XPe, you might be able to create the
image to include the performance counters (ask in the XP embedded group).
Otherwise the only thing I can think of is use the Win32 APIs.
--
Phil Wilson [MVP Windows Installer]
----
We are receiving the following error on XP Embedded only
when calling the C#
System.Diagnostics.Process.GetProcessesByName method:

D:\_WTA>calc_test_process.exe
System.InvalidOperationException: Process performance
counter is disabled, so th
e requested operation cannot be performed.
at System.Diagnostics.NtProcessManager.GetProcessInfos
(PerformanceCounterLib
library)
at System.Diagnostics.NtProcessManager.GetProcessInfos
(String machineName, Bo
olean isRemoteMachine)
at System.Diagnostics.ProcessManager.GetProcessInfos
(String machineName)
at System.Diagnostics.Process.GetProcessesByName (String
processName, String m
achineName)
at System.Diagnostics.Process.GetProcessesByName (String
processName)
at Calc_Test_Process.Class1.Main(String[] args)


This is using a small test program recommended by a
previous post:

try
{
Process [] localByName =
Process.GetProcessesByName("calc");
Console.WriteLine
(localByName.Length);
}
catch(Exception ex)
{
Console.WriteLine
(ex.ToString());
}

The code works fine on Windows 2000 / NT Manager
Workstation. Running Performance Monitor shows the
counters ok, and searching the registry for: "Disable
Performance Counters" set to 1 yields no results.

Any idea?

Thanks,
Burkhard
SQA Tester


.
.
 

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