System.Diagnostics.Process throws System.NotSupportedException

J

Joe K

I just recently ported an application from .Net 1.1 to .Net 2.0 and am
getting the below exception. Basically it looks like
Process.TotalProcessTime and Process.StartTime now throw an exception when I
try to retrieve these properties from a remote system (in this case remote
system in Win2K). Does anyone understand wy? I looked at the underlying
..Net code, and while there are some changes between .Net 1.1 and 2.0,
Microsoft is continuing to use the Process performance counter object for
remotely retrieving this information. This object certainly has counters
that provide this information, so I am at a loss as to why it would fail.

Any help would be appreciated. Thanks in advance.



System.NotSupportedException : Feature is not supported for remote machines.
[Flags=1]
RemoteStackTrace:
at System.Diagnostics.Process.EnsureState(State state)
at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean
throwIfExited)
at System.Diagnostics.Process.GetProcessTimes()
at System.Diagnostics.Process.get_TotalProcessorTime()
at MyProduct.RequestHandlers.ProcessInfoHandler.execute() in
C:\sandbox\MyProduct\Proces.cs:line 86
 
J

Joe K

To reproduce, just create a console application for the below code in .Net
2.0. If you run the same code under .Net 1.1, it works fine. This property
is nothing more than the "% Processor Time" performance counter of the
"Process" performance counter object - so there is no reason why this should
fail.



using System;
using System.Diagnostics;

namespace TestProcess
{
class Program
{
static void Main(string[] args)
{
try
{
foreach (Process process in Process.GetProcesses("x.x.x.x"))
{
Console.WriteLine(process.TotalProcessorTime);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.WriteLine(ex.StackTrace);
}
}
}
}
 
S

Stephany Young

Whether or not the information is obtainable or not is irrelevant.

The point is that someone somewhere made a decision, for whatever reason, to
not support that feature for remote machines.

Now, as to establishing the who, the why and the wherefores of the decision,
you've probably got more chance of winning the lottery.
 
J

Joe K

So the answer from Microsoft is that this change was intentional due to an
internal change in how the data is collected, but they mistakenly did not
update the documentation to reflect.

Below is a rough cut of what works and does not work remotely.

ProcessName - OK
Id - OK
MachineName - OK
BasePriority - OK
ExitCode failed Feature is not supported for remote machines.
ExitTime failed Feature is not supported for remote machines.
Handle failed Feature is not supported for remote machines.
HandleCount - OK
HasExited failed Feature is not supported for remote machines.
MainModule failed Feature is not supported for remote machines.
MainWindowHandle failed Feature is not supported for remote machines.
MaxWorkingSet failed Feature is not supported for remote machines.
MinWorkingSet failed Feature is not supported for remote machines.
Modules failed Feature is not supported for remote machines.
NonpagedSystemMemorySize64 - OK
PagedMemorySize64 - OK
PagedSystemMemorySize64 - OK
PeakPagedMemorySize64 - OK
PeakVirtualMemorySize64 - OK
PeakWorkingSet64 - OK
PriorityBoostEnabled failed Feature is not supported for remote machines.
PriorityClass failed Feature is not supported for remote machines.
PrivateMemorySize64 - OK
PrivilegedProcessorTime failed Feature is not supported for remote
machines.
ProcessorAffinity failed Feature is not supported for remote machines.
Responding failed Feature is not supported for remote machines.
SessionId - OK
StandardError failed StandardError has not been redirected.
StandardInput failed StandardIn has not been redirected.
StandardOutput failed StandardOut has not been redirected or the process
hasn't started yet.
StartInfo System.Diagnostics.ProcessStartInfo
StartTime failed Feature is not supported for remote machines.
SynchronizingObject
TotalProcessorTime failed Feature is not supported for remote machines.
UserProcessorTime failed Feature is not supported for remote machines.
VirtualMemorySize64 - OK
WorkingSet64 - OK
 

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