using System.Configuration; using System.Data; using System.Windows; namespace PetWashControl { /// /// Interaction logic for App.xaml /// public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { base.OnStartup(e); // 全局异常处理 this.DispatcherUnhandledException += (s, args) => { MessageBox.Show($"应用程序错误:\n{args.Exception.Message}\n\n{args.Exception.StackTrace}", "错误", MessageBoxButton.OK, MessageBoxImage.Error); args.Handled = true; }; } } }