0

I am writing an WPF app and annoyed by an unhandled exception that can't be caught by any of my try blocks. So I added these two mighty exception handlers in my app.xml.cs:

this.Dispatcher.UnhandledException += Application_DispatcherUnhandledException;
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

But they don't work for me. I am still getting this crash: App has stopped working, problem event name: APPCRASH, fault module name: clr.dll

What do I do now to find the problem? I seem to have already put try/catch blocks wherever possible.

Thanks in advance.

H.B.
  • 166,899
  • 29
  • 327
  • 400
Charlie
  • 764
  • 2
  • 13
  • 24
  • Look in the Output window for the exit code. I'll guess at either a StackOverflowException or an ExecutionEngineException. Very serious crashes, kaboom and over, do not pass Go. – Hans Passant Mar 07 '12 at 01:29

1 Answers1

0

You cant catch everything.

Some exceptions can even when handle can still leave your program in an unstable state, so it will still crash, even if the exception has been handled.

I believe these exceptions are not "catchable" and you will have to find why they are being caused.

And a general programming rule is to never catch exceptions silently, and let them "pop up" if you cant handle them correctly.

Adding try blocks in order to not crash your program really is a bad idea. You should figure out why its throwing exceptions. Plus exceptions are more costly ressource wise than conditions.

Ressources :

Partly crashing application? How can I catch uncatchable exceptions?

First Chance exceptions

Community
  • 1
  • 1
squelos
  • 1,189
  • 6
  • 16
  • Hi squelos, the reason of trying to catch all exceptions is that with the exception information I can find out what is going wrong. Now the app is just crashing without any useful information. – Charlie Mar 06 '12 at 23:47