Getting .Net application to close on crash

I have a .NET 4 application running on Windows Server 2008 R2 in which I use a separate workflow to manage its life cycle (i.e., detect on / unexpected shutdown / reboot). This is great for typical conditions. However, when the application throws an exception, Windows invokes a debug window to debug the application. I just want the application to crash, so a process runner can detect a failure and manage accordingly.

How can I allow closing an application for an exception?

+3
source share
3 answers

Add a handler to Application.ThreadExceptionand in the handler, register the event, and then exit beautifully.

AppDomain.CurrentDomain.UnhandledException.

MSDN

: .. Alex

+4

" ".

Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
+1

You must add a global exception handler or try / catch to clear the resources, register an error, and close the application normally.

0
source

All Articles