namespace PrintServiceTray; static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { try { // Prevent multiple instances bool createdNew; using var mutex = new Mutex(true, "LAAPC_PrintServiceTray_Mutex", out createdNew); if (!createdNew) { MessageBox.Show("LAAPC Print Service Tray is already running.", "Already Running", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } ApplicationConfiguration.Initialize(); Application.Run(new TrayApplicationContext()); GC.KeepAlive(mutex); } catch (Exception ex) { MessageBox.Show($"Fatal error: {ex.Message}\n\n{ex.StackTrace}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }