How to get rid of console in windows forms

  • Thread starter Thread starter James Carnley
  • Start date Start date
J

James Carnley

I am learning how to use windows forms and I have come across a small
problem. Whenever I run my program it opens a console window before
launching the windows form. The console doesnt go away until the program
exits. When you use VS.net to make a windows application it makes a form
without a console and I dont know why.

What specifies whether a program starts with a console or not?

I know that this code is probobly not right but I just made the most
basic thing I could.

Code:

using System;
using System.Windows.Forms;

namespace Tetris
{
class MainClass : System.Windows.Forms.Form
{
static void Main(string[] args)
{
Application.Run(new MainClass());
}
}
}
 
Hi James,

It sounds like you are compiling your application as a Console app, which is
the default on the command-line. To compile it as a Windows App, change
your target to winexe.

csc /target:winexe myWinProg.cs

In VS.NET, look at project properties and notice that there is an Output
Type entry in the property grid. When selected, it displays a drop-down
list where you can pick the type of program you want to compile. It should
be set to Windows Application. If you changed it to Console Application,
you would see the same behavior that you see now with the Console window
popping up.

Joe
 
Back
Top