Robustly detecting an error when starting an app via code

S

Simon

Hi everyone,

Can anyone tell me if there is a standard way of detecting an error in a
process that I've started using the .net framework's
System.Diagnostics.Process class?

I need to regularly call a secondary application but be able to tell if
a problem has occured with it and log the error (and then probably
restart it)

Can anyone tell me how to detect the error in the running process?

Thanks to anyone who can advise

Best regards

Simon
 
N

Nicholas Paldino [.NET/C# MVP]

Simon,

You can't do this in a generic manner. If anything, you have to have
knowledge of the process and how to retrieve any error that occurs in the
process. The only generic way of handling an error is to use the ExitCode
property on the Process class, but even then, the return values are specific
to the application being run.
 
B

Ben Voigt [C++ MVP]

Nicholas Paldino said:
Simon,

You can't do this in a generic manner. If anything, you have to have
knowledge of the process and how to retrieve any error that occurs in the
process. The only generic way of handling an error is to use the ExitCode
property on the Process class, but even then, the return values are
specific to the application being run.

In addition to the exit code, you can capture output from a console
application, or some programs can be configured to write a log. Another
option might be to start the process under OS debug and capture
OutputDebugString calls (that's what .NET's TraceListener uses to send
messages by default).
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Simon said:
Hi everyone,

Can anyone tell me if there is a standard way of detecting an error in a
process that I've started using the .net framework's
System.Diagnostics.Process class?

I need to regularly call a secondary application but be able to tell if a
problem has occured with it and log the error (and then probably restart
it)

Can anyone tell me how to detect the error in the running process?

Thanks to anyone who can advise

Best regards

Simon
 

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