static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var handler = new ThreadExceptionHandler(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); Application.ThreadException += handler.Application_ThreadException; SystemInfo.MainAssembly = System.Reflection.Assembly.GetEntryAssembly().GetName().Name; SystemInfo.StartupPath = Application.StartupPath; SystemInfo.AppIco = Path.Combine(Application.StartupPath, SystemInfo.AppIco); #region check and download new version program 启动自动升级 bool bHasError = false; IAutoUpdater autoUpdater = new AutoUpdater(); try { autoUpdater.Update(); } catch (WebException ex) { LogHelper.WriteException(ex); MessageBoxHelper.ShowErrorMsg("连接自动升级服务器出错,请检查网络连接或联系软件提供商。"); bHasError = true; } catch (XmlException ex) { LogHelper.WriteException(ex); bHasError = true; MessageBoxHelper.ShowErrorMsg("AutoUpdate Error:Download the upgrade file error"); } catch (NotSupportedException ex) { LogHelper.WriteException(ex); bHasError = true; MessageBoxHelper.ShowErrorMsg("AutoUpdate Error:Upgrade address configuration error"); } catch (ArgumentException ex) { LogHelper.WriteException(ex); bHasError = true; MessageBoxHelper.ShowErrorMsg("AutoUpdate Error:Download the upgrade file error"); } catch (Exception ex) { LogHelper.WriteException(ex); bHasError = true; MessageBoxHelper.ShowErrorMsg("AutoUpdate Error:An error occurred during the upgrade process"); } finally { if (bHasError == true) { try { autoUpdater.RollBack(); } catch (Exception ex) { LogHelper.WriteException(ex); } } } #endregion // 获取配置信息 try { GetConfig(); } catch (Exception ex) { MessageBoxHelper.ShowErrorMsg(ex.Message); } SystemInfo.WebHostUrl = ConfigurationManager.AppSettings["WebHostUrl"]; if (SystemInfo.MultiLanguage) { try { // 多语言国际化加载 ResourceManagerWrapper.Instance.LoadResources(Path.Combine(Application.StartupPath, "Resource/Localization/")); // 从当前指定的语言包读取信息 RDIFrameworkMessage.GetLanguageResource(); } catch (Exception ex) { FileHelper.WriteException(ex, "登录异常.txt"); } } // 初始化服务 RDIFrameworkService.Instance.InitService(); Form mainForm = BasePageLogic.GetForm(SystemInfo.MainAssembly, SystemInfo.MainForm); Application.Run(mainForm); }