If this is a Windows Forms application, it is likely that the unhandled exception gets to the window message pump, so you will never see it. To handle this, see my answer here .
If it is a Windows service, the exception may appear in the background thread and not be redirected back to your main thread. To handle this, you need to translate any background thread back to the main thread, and the exception will be thrown there so you can catch it.
If this is a console application, then I'm a bit puzzled.
EDIT . Your comment says this is a Windows Forms application. In this case, you probably do not see the exception, because it is handled by the built-in Windows Forms exception handler, which by default does the following:
- Catches an unhandled managed exception when:
- no debugger and
- An exception occurs when processing window messages and
- jitDebugging = false in App.Config.
- Shows a dialog for the user and prevents the termination of the application.
You can disable this behavior by setting jitDebugging = true in App.Config. You can then see the unhandled exception by registering for the Application.ThreadException event, for example. in C #:
Application.ThreadException += new Threading.ThreadExceptionHandler(CatchExceptions);
source share