1.取消在App.xaml中设置StartUpUrl
2.在后台的APP.Xaml.cs如下设置,先绑定异常处理的handle,再设置StartUpUrl,可以实现在前台设置一样的效果
public App() { App.Current.DispatcherUnhandledException += Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; this.StartupUri = new Uri("MainWIndow.xaml", UriKind.Relative); } void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { throw new NotImplementedException(); } void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { throw new NotImplementedException(); }