private static void LogUnhandledExceptions() { AppDomain.CurrentDomain.UnhandledException += (sender, args) => { DomainPorts.LogMessageStore.StoreError($"Unhandled exception:\r\n{args?.ExceptionObject?.ToString()}"); #if DEBUG if (Debugger.IsAttached) Debugger.Break(); #endif }; TaskScheduler.UnobservedTaskException += (sender, args) => { DomainPorts.LogMessageStore.StoreError($"UnobservedTaskException:\r\n{args?.Exception?.ToString()}"); #if DEBUG if (Debugger.IsAttached) Debugger.Break(); #endif }; }
202800cookie-checkC# Global exception handling