Robustly detecting an error when starting an app via code

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon

    #1

    Robustly detecting an error when starting an app via code

    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.Diagnost ics.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
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Robustly detecting an error when starting an app via code

    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.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Simon" <nothanks@hotma il.comwrote in message
    news:Ocr45ly7HH A.484@TK2MSFTNG P06.phx.gbl...
    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.Diagnost ics.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

    Comment

    • Ben Voigt [C++ MVP]

      #3
      Re: Robustly detecting an error when starting an app via code


      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omwrote in
      message news:OUdBUsy7HH A.484@TK2MSFTNG P06.phx.gbl...
      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
      OutputDebugStri ng calls (that's what .NET's TraceListener uses to send
      messages by default).
      >
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m
      >
      "Simon" <nothanks@hotma il.comwrote in message
      news:Ocr45ly7HH A.484@TK2MSFTNG P06.phx.gbl...
      >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.Diagnos tics.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
      >
      >

      Comment

      • Simon

        #4
        Re: Robustly detecting an error when starting an app via code

        Thanks guys - very much appreciated

        Comment

        Working...