G
Guest
I have a class in my application that monitors for a few given processes
going up or down so that the user can be shown visually that something is
wrong. This class works fine for Windows 2003 SP1 but as soon as I apply SP2
I get many exceptions like:
System.ComponentModel.Win32Exception: Access is denied
at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32
access, Boolean throwIfExited)
at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean
throwIfExited)
at System.Diagnostics.Process.GetProcessHandle(Int32 access)
at System.Diagnostics.Process.OpenProcessHandle()
at System.Diagnostics.Process.set_EnableRaisingEvents(Boolean value)
The EnableRaisingEvents seems to be the culprit. Sample code:
Process [] allProcesses = Process.GetProcesses();
foreach( Process p in allProcesses )
{
if( p.Id != 0 && p.HasExited == false)
{
p.Exited += new EventHandler( ProcessTerminatedEvent);
p.EnableRaisingEvents = true;
}
}
This is using Visual Studio 2003 and the .NET 1.1 Framework. I trap and
ignore these exceptions on the processes that I don't care about but I'm
getting this on the service that my GUI app is starting as well as the 2
processes that the service starts.
I can't find any answers elsewhere on why this is a problem in SP2 for
Windows 2003. The full source code is available to anyone who needs it but
there's not much more since I tried to trim the problem down to the bare
minimum.
Thank you for any assistance you can give,
George Davis
going up or down so that the user can be shown visually that something is
wrong. This class works fine for Windows 2003 SP1 but as soon as I apply SP2
I get many exceptions like:
System.ComponentModel.Win32Exception: Access is denied
at System.Diagnostics.ProcessManager.OpenProcess(Int32 processId, Int32
access, Boolean throwIfExited)
at System.Diagnostics.Process.GetProcessHandle(Int32 access, Boolean
throwIfExited)
at System.Diagnostics.Process.GetProcessHandle(Int32 access)
at System.Diagnostics.Process.OpenProcessHandle()
at System.Diagnostics.Process.set_EnableRaisingEvents(Boolean value)
The EnableRaisingEvents seems to be the culprit. Sample code:
Process [] allProcesses = Process.GetProcesses();
foreach( Process p in allProcesses )
{
if( p.Id != 0 && p.HasExited == false)
{
p.Exited += new EventHandler( ProcessTerminatedEvent);
p.EnableRaisingEvents = true;
}
}
This is using Visual Studio 2003 and the .NET 1.1 Framework. I trap and
ignore these exceptions on the processes that I don't care about but I'm
getting this on the service that my GUI app is starting as well as the 2
processes that the service starts.
I can't find any answers elsewhere on why this is a problem in SP2 for
Windows 2003. The full source code is available to anyone who needs it but
there's not much more since I tried to trim the problem down to the bare
minimum.
Thank you for any assistance you can give,
George Davis