Unhandled Exceptions

  • Thread starter Christoph Basedau
  • Start date
C

Christoph Basedau

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
 
P

Peter Duniho

Christoph said:
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
 
C

Christoph Basedau

Christoph said:
[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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top