static void Main() { Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Application.ApplicationExit += new EventHandler(Application_ExitHandler); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); try { if (!AppDataManager.loadCfgFile()) { MessageBox.Show(ErrorHelper.ConfigFileCorrupted, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { Logger.NewLog(ex, "Major config file problem at start."); MessageBox.Show(String.Format(ErrorHelper.ConfigFileFailure, Logger.LogsFolderPath), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } if (IsFirstInstance()) { Application.Run(new MainForm(true)); } else { Application.Run(new MainForm(false)); } }