public App()
{
DispatcherUnhandledException += App_DispatcherUnhandledException;
}
void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
{
MessageBox.Show("程序异常." + Environment.NewLine + e.Exception.Message);
//Shutdown(1);
e.Handled = true;
}
http://www.cnblogs.com/DebugLZQ/p/3161185.html