protected override void OnCreateMainForm() { // If /exit was passed on the command line, then just exit immediately foreach (string commandLineArg in Environment.GetCommandLineArgs()) { if (commandLineArg.ToUpperInvariant() == "/EXIT") { Environment.Exit(1); } } if (!OsUtils.Windows()) { // Mono has a bug which causes the useDefaultCredentials attribute to be // treated as invalid, so clear the default proxy to prevent an exception WebRequest.DefaultWebProxy = null; } try { // Add TLS 1.1 and 1.2 to allowed protocols for HTTPS requests // Constants are not defined until .NET 4.5, so use the values ServicePointManager.SecurityProtocol |= (SecurityProtocolType)0x00000300 | // SecurityProtocolType.Tls11 (SecurityProtocolType)0x00000C00; // SecurityProtocolType.Tls12 } catch (NotSupportedException) { if (OsUtils.Windows()) { MessageBox.Show( "The .NET framework needs an update (to enable TLS 1.1 and 1.2) before Radio Downloader can run." + Environment.NewLine + Environment.NewLine + "Please check for available updates and install all of those which relate to the .NET framework.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); Environment.Exit(1); } throw; } // Set up the application database and perform any required updates or cleanup if (!DatabaseInit.Startup()) { Environment.Exit(1); } this.MainForm = new Main(); this.StartupNextInstance += ((Main)this.MainForm).App_StartupNextInstance; }
private void App_Startup(object sender, StartupEventArgs e) { // If /exit was passed on the command line, then just exit immediately foreach (string commandLineArg in Environment.GetCommandLineArgs()) { if (commandLineArg.ToUpperInvariant() == "/EXIT") { e.Cancel = true; return; } } // Set up the application database and perform any required updates or cleanup if (!DatabaseInit.Startup()) { e.Cancel = true; return; } }