private static void Initialize() { try { //Check if a debugger is attached if (DebugDetector.Detect()) { Log.Write("Debugging CSS is prohibited."); return; } //See if the client has recently been updated if (AutoUpdate.CheckTemporaryProcess()) { return; } //Ticket #46 - Prevent multiple instances of the launcher var runningProcesses = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName); int matchCounter = 0; foreach (var runningProcess in runningProcesses) { if (runningProcess.MainModule.FileName.Equals(Process.GetCurrentProcess().MainModule.FileName) == true) { matchCounter++; } } if (matchCounter > 1) { MessageBox.Show("Only one instance of " + Process.GetCurrentProcess().MainModule.FileName + " can be run at a time. Please close other versions of the ACSS Launcher and try again.", "ACSS Launcher Already Running", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); using (ServiceHandler.Service) { UpdateCheckForm updateCheckForm = new UpdateCheckForm(); if (updateCheckForm.HasPendingUpdates == true) { if (updateCheckForm.ShowDialog() != DialogResult.OK) { return; } } // If you need to upgrade things on the end users system during an auto-update push, put them in here. string returnMessage; if (Install.Upgrade.PerformUpgradeTasks(out returnMessage) == false) { MessageBox.Show(returnMessage, "Upgrade canceled.", MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } bool showLoginDialog = false; //Check if the credentials are already stored if (ServiceHandler.CheckLogin() == true) { var launcherStartupProgress = new LauncherStartupProgress(); launcherStartupProgress.TopMost = true; var launcherStartupProgressResult = launcherStartupProgress.ShowDialog(); if (launcherStartupProgressResult == DialogResult.OK) { StartMainForm(); } //else if (launcherStartupProgressResult == DialogResult.Abort) // return; else { showLoginDialog = true; } } if (ServiceHandler.CheckLogin() == false || showLoginDialog == true) { //Create Login prompt using (var loginForm = new LoginForm()) { if (loginForm.ShowDialog() != DialogResult.OK) { return; } var launcherStartupProgress = new LauncherStartupProgress(); launcherStartupProgress.TopMost = true; if (launcherStartupProgress.ShowDialog() != DialogResult.OK) { return; } StartMainForm(); } } } } catch (Exception ex) { File.WriteAllText("ExceptionLog.txt", ex.ToString()); throw; } }