CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    129

    [RESOLVED] Catching when an application closes/crashes..in release mode.

    I have an app that will run for a variable amount of time and then...disappear.

    Usually, when this application crashes (it does happen), I'll get a "Windows has encountered an error and needs to close..." window. I'm also catching issues in debug mode, but I also need to test in release.

    Is there a way to intercept and log this disappearing act? I'm thinking of writing to a log file on this event when the app "disappears" but I haven't yet determined what function, exactly, I should look for.

    Can someone shed some light on this problem?

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    Re: Catching when an application closes/crashes..in release mode.

    Wrap main in a try/catch block and log the exception and stack trace. Next time it crashes you know where to start looking.

  3. #3
    Join Date
    May 2007
    Posts
    1,546

    Re: Catching when an application closes/crashes..in release mode.

    http://msdn.microsoft.com/en-us/libr...exception.aspx

    That is what you need. It'll allow you to log information on any unhandled exception.
    www.monotorrent.com For all your .NET bittorrent needs

    NOTE: My code snippets are just snippets. They demonstrate an idea which can be adapted by you to solve your problem. They are not 100% complete and fully functional solutions equipped with error handling.

  4. #4
    Join Date
    Jun 2002
    Location
    Monte Carlo
    Posts
    129

    Re: Catching when an application closes/crashes..in release mode.

    Thank you both for all your help! Mutant Fruit, that link was exactly what I was looking for.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured