Unhandled Exceptions

Discussion in 'Microsoft C# .NET' started by Christoph Basedau, Jun 1, 2010.

  1. Hi

    in order to give the user a last info before his app dies, due to
    uncaught exceptions
    we implemented the code from msdn (<URL:http://msdn.microsoft.com/en-
    us/library/ms223898.aspx>) that utilizes

    Application.SetUnhandled,
    Application.ThreadException,
    AppDomain.CurrentDomain.UnhandledException.

    As expected unhandled non-UI exceptions no go through our method
    'OnUnhandledException'
    and a last grave note is displayed to our user.
    Nonetheless after 'OnUnhandledException' is out of scope, the runtime
    still
    crashes with sth like "windows encountered a problem with app.exe,
    app.exe is shutdown".
    This msg also occurs when unhandled exceptions are not directed to any
    handler.

    Is there a way to suppress this OS-crash message?

    Thx
    Christoph
     
    Christoph Basedau, Jun 1, 2010
    #1
    1. Advertisements

  2. Christoph Basedau

    Peter Duniho Guest

    Christoph Basedau wrote:
    > Hi
    >
    > in order to give the user a last info before his app dies, due to
    > uncaught exceptions
    > we implemented the code from msdn (<URL:http://msdn.microsoft.com/en-
    > us/library/ms223898.aspx>) that utilizes
    >
    > Application.SetUnhandled,
    > Application.ThreadException,
    > AppDomain.CurrentDomain.UnhandledException.
    >
    > As expected unhandled non-UI exceptions no go through our method
    > 'OnUnhandledException'
    > and a last grave note is displayed to our user.
    > Nonetheless after 'OnUnhandledException' is out of scope, the runtime
    > still
    > crashes with sth like "windows encountered a problem with app.exe,
    > app.exe is shutdown".
    > This msg also occurs when unhandled exceptions are not directed to any
    > handler.
    >
    > Is there a way to suppress this OS-crash message?


    Yes. Catch the exception that is currently unhandled.

    The UnhandledException and ThreadException events don't allow you to
    handle the exception. They just allow you to learn when an exception
    has been unhandled. But, if the handlers for those events are called,
    then it means you still have an unhandled exception. And if you still
    have an unhandled exception, then Windows is still going to see the
    program crash.

    Pete
     
    Peter Duniho, Jun 1, 2010
    #2
    1. Advertisements

  3. On 1 Jun., 17:45, Peter Duniho <>
    wrote:

    > Christoph Basedau wrote:
    > > [Handling uncaught exceptions] using
    > > Application.SetUnhandledExceptionMode,
    > > Application.ThreadException,
    > > AppDomain.CurrentDomain.UnhandledException.
    > >
    > > still raises "windows OS-crash message"

    >
    > > Is there a way to suppress this OS-crash message?

    >
    > Yes. Catch the exception that is currently unhandled.
    >
    > The UnhandledException and ThreadException events don't allow you to
    > handle the exception. They just allow you to learn when an exception
    > has been unhandled. But, if the handlers for those events are called,
    > then it means you still have an unhandled exception. And if you still
    > have an unhandled exception, then Windows is still going to see the
    > program crash.



    Hi Pete,
    thx for your reply
    Sounds somehow reasonable to me these eventhandlers don't
    automagically handle any exception.


    Chris
     
    Christoph Basedau, Jun 2, 2010
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shravan

    Catching unhandled exceptions in application

    Shravan, Oct 31, 2003, in forum: Microsoft C# .NET
    Replies:
    2
    Views:
    202
    Brian L. Gorman
    Oct 31, 2003
  2. James Hancock

    Catching ALL Unhandled Exceptions

    James Hancock, Jan 12, 2004, in forum: Microsoft C# .NET
    Replies:
    5
    Views:
    211
    Mike Junkin
    Jan 13, 2004
  3. Replies:
    1
    Views:
    280
    Ignacio Machin \( .NET/ C# MVP \)
    Dec 20, 2005
  4. Andreas van de Sand

    Unhandled Exceptions

    Andreas van de Sand, Jul 5, 2006, in forum: Microsoft C# .NET
    Replies:
    3
    Views:
    183
    Guest
    Sep 13, 2006
  5. Simon Tamman

    Unhandled Exceptions - Revisited

    Simon Tamman, Sep 10, 2006, in forum: Microsoft C# .NET
    Replies:
    1
    Views:
    125
    Guest
    Sep 11, 2006
Loading...

Share This Page