R
rmurrell
Guest
This is kind of a complicated problem; I'll try to explain it as clearly as I can.
On one of the servers where I work, there lives a certain commercial application (as opposed to one developed in-house) which will sometimes throw a "This program has stopped working" error. When this happens, the application naturally needs to be restarted.
We are trying to devise a method to monitor the application so we can be altered of this event when it occurs, instead of having to wait for users' error reports. My idea is to use a Windows service to monitor the application.
I have tried using the below code to monitor the process in question:
Process[] proc = Process.GetProcessesByName([process name]);
bool isRunning = proc.Length > 0;
if (!isRunning)
{
eventLog1.WriteEntry("Application does not appear to be running");
}
else if (logOK)
{
eventLog1.WriteEntry("Application appears to be running");
}
But all this can tell me is whether the application is running or not, and an application throwing the "stopped working" error is still running. Does anyone know how to listen for this error from C# code?
To be clear, I am talking about creating a custom application to monitor a second, separate application that I did not write and over the source code of which I have no control.
Continue reading...
On one of the servers where I work, there lives a certain commercial application (as opposed to one developed in-house) which will sometimes throw a "This program has stopped working" error. When this happens, the application naturally needs to be restarted.
We are trying to devise a method to monitor the application so we can be altered of this event when it occurs, instead of having to wait for users' error reports. My idea is to use a Windows service to monitor the application.
I have tried using the below code to monitor the process in question:
Process[] proc = Process.GetProcessesByName([process name]);
bool isRunning = proc.Length > 0;
if (!isRunning)
{
eventLog1.WriteEntry("Application does not appear to be running");
}
else if (logOK)
{
eventLog1.WriteEntry("Application appears to be running");
}
But all this can tell me is whether the application is running or not, and an application throwing the "stopped working" error is still running. Does anyone know how to listen for this error from C# code?
To be clear, I am talking about creating a custom application to monitor a second, separate application that I did not write and over the source code of which I have no control.
Continue reading...