static void Main() { #if DEBUG Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mainWindow = new MainWindow(); Application.Run(mainWindow); #else try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mainWindow = new MainWindow(); Application.Run(mainWindow); } catch (Exception ex) { //Write ex.Message to a file using (StreamWriter outfile = new StreamWriter(@".\error" + DateTime.Now.ToShortDateString() + DateTime.Now.ToShortTimeString() + ".txt")) { outfile.Write(ex.Message.ToString()); } } #endif }
/// <summary> /// Checks if the pointer to the main window is null, and sets it to the current instance of the main window if it is. /// </summary> private static void refreshMainWindow() { if (mainWindow == null) { mainWindow = Program.MainWindow; } }