views:

95

answers:

1

Hi

I was wandering why when I create console application and 'transform' the main method to look identically with main method auto-generated when creating windows forms project, the console still appears on the screen:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Windows.Forms;

namespace Chapter16
{
    static class Program
    {
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new CultureTest());
        }
    }
}

This code is identical with the code located in Program.cs from windows forms application. The problem is that console still appears on the screen which is not the case in windows forms project. Why is that?

Kind Regadrs PK

+5  A: 

You should set the target type in project properties to "Windows Application". This is equivalent to /target:winexe compiler switch. It'll alter the subsystem in binary header to tell Windows not to open up a shell window.

Mehrdad Afshari
Indeed. Thank you.
pkolodziej