我的应用程序中有以下代码在未处理的异常后运行:
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
var exception = e.ExceptionObject as Exception;
if (exception != null) MessageBox.Show(exception.Message + " - " + exception.StackTrace);
}
但即使我捕捉到未处理的异常,我的 Windows 移动应用程序也会关闭。当我捕获未处理的异常时如何防止关闭应用程序。我从不想关闭我的应用程序。我想在这种情况下打开登录表单或其他任何不关闭应用程序的东西。
所以我想要的是防止关闭应用程序出现未处理的异常,例如网络关闭,......
我不能在每个代码中都使用 try catch ....
知道如何在网络关闭或任何其他未处理的异常时防止关闭应用程序吗?