private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { Logger logger = new Logger(); string name = Assembly.GetExecutingAssembly().GetName().Name; string text = Application.ExecutablePath.ToString(); string filePath = text.Substring(0, text.Length - name.Length - 4) + "debug.txt"; logger.filePath = filePath; try { logger.log(e.Exception.ToString()); } catch { } CustomErrorDialogBox customErrorDialogBox = new CustomErrorDialogBox(); customErrorDialogBox.Text = "ibVPN client error message"; customErrorDialogBox.pictureBox1.Image = customErrorDialogBox.imageListMessages.Images[1]; customErrorDialogBox.rchInfo.Text = e.Exception.ToString(); customErrorDialogBox.TopMost = true; customErrorDialogBox.btnCopyToClipboard.Click += new EventHandler(Program.BtnCopyToClipboard_Click); Program.error = customErrorDialogBox.rchInfo.Text; customErrorDialogBox.ShowDialog(); if (customErrorDialogBox.Quit) { logger.log("Eroare netrata - se va rula RestoreDNS din ApplicationThreadException - Programm.cs"); Program.RestoreDNS(); Program.RestoreDefaultRoute(); Environment.Exit(1); } }
private static void MainMethod() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); LoginForm mainForm = new LoginForm(); Program.SetInitialDebugMode(); Program.SetInitialDNS(); Program.adaptors = Program.dnsManager.PrepareAdaptors(true); Application.ThreadException += new ThreadExceptionEventHandler(Program.Application_ThreadException); try { string name = Assembly.GetExecutingAssembly().GetName().Name; string text = Application.ExecutablePath.ToString(); Hashtable settings = Program.GetSettings(text.Substring(0, text.Length - name.Length - 4) + "\\UserSettings.xml"); if ((string)settings["remember"] == "True") { if ((string)settings["autologin"] == "True") { Application.Run(new LoginForm(true)); } else { Application.Run(mainForm); } } else { Application.Run(mainForm); } } catch (Exception ex) { Logger logger = new Logger(); string name2 = Assembly.GetExecutingAssembly().GetName().Name; string text2 = Application.ExecutablePath.ToString(); string filePath = text2.Substring(0, text2.Length - name2.Length - 4) + "debug.txt"; logger.filePath = filePath; try { logger.log(ex.ToString()); } catch { } CustomErrorDialogBox customErrorDialogBox = new CustomErrorDialogBox(); customErrorDialogBox.Text = "ibVPN client error message"; customErrorDialogBox.pictureBox1.Image = customErrorDialogBox.imageListMessages.Images[1]; customErrorDialogBox.rchInfo.Text = ex.ToString(); customErrorDialogBox.TopMost = true; customErrorDialogBox.btnCopyToClipboard.Click += new EventHandler(Program.BtnCopyToClipboard_Click); Program.error = customErrorDialogBox.rchInfo.Text; customErrorDialogBox.ShowDialog(); if (customErrorDialogBox.Quit) { logger.log("Eroare netratata - se va rula RestoreDNS din MainMethod - Programm.cs"); Program.RestoreDNS(); Program.RestoreDefaultRoute(); Environment.Exit(1); } } }