using DevExpress.LookAndFeel; using DevExpress.Skins; using DevExpress.UserSkins; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Windows.Forms; namespace DataSimulation.Forms { internal static class Program { static Program() { AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", "AddIns;"); string paths = Environment.GetEnvironmentVariable("PATH"); var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static); var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance); m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", "AddIns;" }); AppDomain.CurrentDomain.UnhandledException += (sender, e) => { var args = e.ExceptionObject as Exception; Serilog.Log.Error(args, "出现未处理的异常,程序即将退出!"); DxHelper.MsgBoxHelper.ShowError("出现未处理的异常,程序即将退出!"); }; Application.ThreadException += (sender, e) => { DxHelper.MsgBoxHelper.ShowError($"出现未处理的线程异常!{e.Exception.Message}"); Serilog.Log.Error(e.Exception, "出现未处理的线程异常"); }; } /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } } }