Dos/Windows program

I am trying to write a program that sometimes is only used in the command line and sometimes is used with a GUI but the thing is when i created the program i said to the IDE it would be a windows from application, when i change the Program.cs (where the main method is) by removing Application.Run(new Form1()) and add code for only cmd the program won't run, i won't get a new cmd window or anything when i start the .exe file, what is causing this behavior and is there a way to get around it

The code i add is simple (just testing if it would work), it is like this:

static void Main(string[] args)
{
Console.Write("What is your name : ");
Console.Write("Hello, {0}! ", Console.ReadLine());
}
Again the program will run if it is like this:

static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}



Answer this question

Dos/Windows program

  • Mark Lines-Davies

    You probably have to change the Project output type to "Console Application". It is under menu: Project -> Properties, Output Type.

    Or you can just create a new Console Application project.

    HTH

    Gonzo


  • Dos/Windows program