using System; using System.Windows.Forms; namespace yjktool { static class Program { [STAThread] static void Main() { // 全局异常兜底:任何未捕获异常弹窗而不是闪退 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += (s, e) => 弹(e.Exception); AppDomain.CurrentDomain.UnhandledException += (s, e) => 弹(e.ExceptionObject as Exception); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } private static void 弹(Exception ex) { try { MessageBox.Show("程序异常(可继续):\n\n" + (ex == null ? "?" : ex.ToString()), "元件库数据工具", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch { } } } }