using LAEPS.ViewModels; using LAEPS.ViewModels.Dialogs; using LAEPS.Views; using LAEPS.Views.Dialogs; using Castle.DynamicProxy; using LAEPS.Views; using System.Configuration; using System.Data; using System.Reflection; using System.Windows; using static System.Runtime.InteropServices.JavaScript.JSType; using LAEPS.PubEvent; using Notifications.Wpf.Core; using Logger; using Common; namespace LAEPS { /// /// Interaction logic for App.xaml /// public partial class App : PrismApplication { protected override Window CreateShell() { //UI线程未捕获异常处理事件 this.DispatcherUnhandledException += OnDispatcherUnhandledException; //Task线程内未捕获异常处理事件 TaskScheduler.UnobservedTaskException += OnUnobservedTaskException; ////多线程异常 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; return Container.Resolve(); } private void OnDispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) { //通常全局异常捕捉的都是致命信息 LoggerHelper.Error(e.Exception.Message,e.Exception.StackTrace); } private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) { LoggerHelper.Error(e.Exception.Message, e.Exception.StackTrace); } private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { //记录dump文件 Exception ex = e.ExceptionObject as Exception; MiniDump.TryDump($"dumps\\Error_{DateTime.Now:yyyy-MM-dd HH-mm-ss-ms}.dmp", MiniDump.Option.WithFullMemory, ex); } protected override void OnInitialized() { var login=Container.Resolve(); login.Show(); } protected override void RegisterTypes(IContainerRegistry containerRegistry) { //注册视图 containerRegistry.RegisterForNavigation("MainView"); containerRegistry.RegisterForNavigation("SettingView"); containerRegistry.RegisterForNavigation("UpdateInfoView"); //注册弹窗 containerRegistry.RegisterDialog("MessageBox"); // 注册通知管理器 INotificationManager NotificationManager = new NotificationManager(); containerRegistry.RegisterInstance(NotificationManager); } } }