Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.