Console Window and CSharp Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michel Racicot

    Console Window and CSharp Form

    Why do I obtain a console Window in addition to my CSharp Form when I do the
    following code:

    using System.Windows. Forms;

    class MyWindow: Form
    {
    }

    class MyApp
    {
    static void Main ()
    {
    Application.Run (new MyWindow ());
    }
    }

    ?


  • Gheorghe Marius

    #2
    Re: Console Window and CSharp Form

    Because the output type of your exe is Console Application instead of
    Windows Application. Set it wo Windows Application and the consolw thingie
    won't appear anymore.

    Cheers,
    Marius.


    "Michel Racicot" <michel.racicot @cognicase.ca> wrote in message
    news:OF9$FMHTDH A.2152@TK2MSFTN GP12.phx.gbl...[color=blue]
    > Why do I obtain a console Window in addition to my CSharp Form when I do[/color]
    the[color=blue]
    > following code:
    >
    > using System.Windows. Forms;
    >
    > class MyWindow: Form
    > {
    > }
    >
    > class MyApp
    > {
    > static void Main ()
    > {
    > Application.Run (new MyWindow ());
    > }
    > }
    >
    > ?
    >
    >[/color]


    Comment

    • Jon Skeet

      #3
      Re: Console Window and CSharp Form

      Michel Racicot <michel.racicot @cognicase.ca> wrote:[color=blue]
      > Why do I obtain a console Window in addition to my CSharp Form when I do the
      > following code:
      >
      > using System.Windows. Forms;
      >
      > class MyWindow: Form
      > {
      > }
      >
      > class MyApp
      > {
      > static void Main ()
      > {
      > Application.Run (new MyWindow ());
      > }
      > }[/color]

      Make the project type a console application instead of a Windows
      application and you'll get both.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      • Michel Racicot

        #4
        Re: Console Window and CSharp Form

        Thank you a lot for the quick answer!

        "Gheorghe Marius" <cghostsoft@hot mail.com> wrote in message
        news:%23J1k$NHT DHA.1572@TK2MSF TNGP12.phx.gbl. ..[color=blue]
        > Because the output type of your exe is Console Application instead of
        > Windows Application. Set it wo Windows Application and the consolw thingie
        > won't appear anymore.
        >
        > Cheers,
        > Marius.
        >
        >
        > "Michel Racicot" <michel.racicot @cognicase.ca> wrote in message
        > news:OF9$FMHTDH A.2152@TK2MSFTN GP12.phx.gbl...[color=green]
        > > Why do I obtain a console Window in addition to my CSharp Form when I do[/color]
        > the[color=green]
        > > following code:
        > >
        > > using System.Windows. Forms;
        > >
        > > class MyWindow: Form
        > > {
        > > }
        > >
        > > class MyApp
        > > {
        > > static void Main ()
        > > {
        > > Application.Run (new MyWindow ());
        > > }
        > > }
        > >
        > > ?
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jon Skeet

          #5
          Re: Console Window and CSharp Form

          Jon Skeet <skeet@pobox.co m> wrote:[color=blue]
          > Michel Racicot <michel.racicot @cognicase.ca> wrote:[color=green]
          > > Why do I obtain a console Window in addition to my CSharp Form when I do the
          > > following code:
          > >
          > > using System.Windows. Forms;
          > >
          > > class MyWindow: Form
          > > {
          > > }
          > >
          > > class MyApp
          > > {
          > > static void Main ()
          > > {
          > > Application.Run (new MyWindow ());
          > > }
          > > }[/color]
          >
          > Make the project type a console application instead of a Windows
          > application and you'll get both.[/color]

          Apologies - I misread the question, thinking that you *wanted* both a
          console and a GUI. Make the project type Win32 Application (or whatever
          it's called - just not Console).

          From the command line, you can build with /t:winexe to do the same
          thing

          --
          Jon Skeet - <skeet@pobox.co m>
          Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

          If replying to the group, please do not mail me too

          Comment

          Working...