This is a minor bug (one I’m willing to live with in the interest of go-live, frankly), but I’m wondering if anyone else has ideas to fix it.
I have a C# WinForms application. When the app is launched via the executable (not via the debugger), the first thing the user sees is a console window, followed by the main window (after pre-loading is complete.)
I’d like to not display the console window. (Like I said, it’s a minor bug.)
The project output is already set to Windows Application.
Here’s (most of) the code for the Main() method. I’ve snipped out various proprietary/security related stuff, replacing it with comments where appropriate.
[STAThread] static void Main() { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // SNIP: Get username from Windows, associate with DB user if (user == null || user.UID == 0 || (user.Active.HasValue && !(user.Active.Value))) { MessageBox.Show(ErrorStrings.UnknownUser, ErrorStrings.TitleBar, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; } // SNIP: Associate user with employee object Application.Run(new MainForm()); } catch (Exception ex) { if (ExceptionPolicy.HandleException(ex, UiStrings.ExceptionPolicy)) { string message = ErrorStrings.UnhandledPreface + ex.ToString(); MessageBox.Show(message, ErrorStrings.TitleBar, MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); } } }
Anyone have any ideas?
My first guess would be to double check your Project Property settings and make sure that the output type is Windows Application and not Console Application.