JaysonFix
JaysonFix

Reputation: 2575

C#, .NET : hide DOS command-prompt window

In C# and .NET, I wrote an application that runs in a Form (using Windows.System.Forms). I use InnoSetup to install and I am able to start the application via Windows' Start button.

My problem: a DOS command-prompt window appears along with the Form. How can I prevent the DOS window from appearing?

Upvotes: 3

Views: 5295

Answers (2)

Graham Clark
Graham Clark

Reputation: 12966

Did you create the application using Visual Studio? If so, in the project properties, in the Application tab, there's a setting called "Output type". If this is set to "Console Application", a command-prompt window will appear when running the program, as well as the form. Setting it to "Windows Application" (the default for Windows Forms projects) will sort this out.

EDIT: Just saw your comment on the other answer. This setting corresponds to the "/target" switch for the compiler. /target:exe will give you the command-prompt, /target:winexe will just show the form. Hopefully anyway! I'm just going by the build output from Visual Studio.

Upvotes: 13

Bojan Rajkovic
Bojan Rajkovic

Reputation: 1706

Sounds like you compiled the application with the wrong target--likely, you need to tell Visual Studio to compile it targeting a GUI executable, not a CLI executable.

You can do this in the project preferences.

Upvotes: 7

Related Questions