error log of third party app from C# app - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

error log of third party app from C# app

havejeethavejeet Posts: 17Member
Hi all,

In my windows application written in C#, I am calling one windows utility...but it is likely to fail the execution of that windows utility execution...How do I log the error of that utility into my C# application?

regards
Jeet

Comments

  • PsightoplazmPsightoplazm Posts: 332Member ✭✭
    Wrap the call you are making with a try/catch

    [code]
    try
    {
    // Make your call here
    }
    catch(Exception e)
    {
    Debug.WriteLine(e.Message);
    Debug.WriteLine(e.StackTrace);
    }
    [/code]

    Another really good practice is to create a fault handler that you can put your default handling in which would allow you to wrap your calls like so:

    [code]
    MyResult = MyFaultHandler.GetResult(
    delegate
    {
    //Put your call here
    });
    [/code]

    This will allow you to set up your handling in one place and if you ever need to change it - you only ever have to change it in one place.
    ><//~Psightoplasm`~
Sign In or Register to comment.