using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Pcb.Common { public static class AppDomainUtil { public static void RegisterUnhandledExeptionHandler() { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); } private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Exception ex = e.ExceptionObject as Exception; if (ex != null) { LogHelper.Error("系统未处理异常", ex); } else { LogHelper.Error("系统未处理异常,并且异常对象为空"); } } } }