C# Beginner Question - Blank Console Appearing?

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 1923 Views - Last Post: 07 April 2012 - 08:36 AM Rate Topic: -----

#16 ssandro  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 05-April 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 07:40 PM

How would I be able to change it from being a Console app to a Winform app in code? I have been googling this forever and I'm having some difficulty finding it. It must be possible to do it without VS haha, and the more I post about this the more I am curious how to fix it in code.

(Note: It isnt a namespace problem, all programs I write are in namespaces. And you can call a class anything you want, I wouldnt understand why you would have to call it Program)

At first I thought doing this would help:

[STAThread]
		public static void Main()
		{	
			Application.EnableVisualStyles();
			Application.SetCompatibleTextRenderingDefault(false);
			Application.Run(new SpellChecker());
		}


But the same problem occurs
Was This Post Helpful? 0
  • +
  • -

#17 ssandro  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 05-April 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 08:00 PM

I have solved the problem! I found this on a tutorial and will post it so that anyone with the same problem as me can also fix it. Who would have thought it had to do with my compile command?

"To produce Windows Applications, the C# CSC compiler has a '/t:WinExe' (/target:WinExe) option. Always remember to use this switch when compiling your final WinForm application.
You might have many times seen WinForm applications (mostly the samples which install with the .NET SDK) with a Ms-Dos windows behind them and wondering, Why does the Ms-Dos window behind GUI applications appear??
Well the answer to this question has already been answered, if you don't use the '/t:WinExe' compiler options then the compiler produces a normal Console Application which has a Ms-Dos window. "
Was This Post Helpful? 2
  • +
  • -

#18 AdamSpeight2008  Icon User is online

  • MrCupOfT
  • member icon


Reputation: 1997
  • View blog
  • Posts: 8,804
  • Joined: 29-May 08

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 08:18 PM

So much easier in/from within VS.
To change the project type from
Attached Image

to


Attached Image

Probably more discover-ible as well, how much time have wasted looking for an answer?

This post has been edited by AdamSpeight2008: 05 April 2012 - 08:20 PM

Was This Post Helpful? 0
  • +
  • -

#19 ssandro  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 05-April 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 08:21 PM

It would have been a lot shorter if people actually helped and answered my question instead of nagging me for not using VS.
Was This Post Helpful? 0
  • +
  • -

#20 AdamSpeight2008  Icon User is online

  • MrCupOfT
  • member icon


Reputation: 1997
  • View blog
  • Posts: 8,804
  • Joined: 29-May 08

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 08:23 PM

We did answer your question.

Quote

Is there any way to make this not happen?

We answered with use VS, but you would accept it as a valid answer.

ssandro: And your not answer mine.

Quote

Probably more discover-ible as well, how much time have wasted looking for an answer?

This post has been edited by AdamSpeight2008: 05 April 2012 - 08:24 PM

Was This Post Helpful? 0
  • +
  • -

#21 ssandro  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 05-April 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 08:55 PM

B/c saying "use VS" isn't an answer. That does not explain whatsoever why a console was appearing. Simply saying "I wrote a console app" doesnt help either - b/c you don't write a console app, you compile a console app. You need to learn how to better educate people in computer science and properly answer there specific questions so that they may learn. Then afterwards you can recommend that they use VS to help quicken their learning. The correct response would have been to say "you have to compile it as a WinForm app", which directly answers my question.
Was This Post Helpful? 0
  • +
  • -

#22 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1212
  • View blog
  • Posts: 4,130
  • Joined: 27-January 10

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 09:25 PM

You're mistaken.

If I were to go into a Python forum and demand someone tell how to do things using KomodoEdit or whatever, the users there would berate me. And this isn't a hypothetical, it happened to me personally! :)

Let's go another direction, go into a Ruby on Rails forums and ask for advice and ignore what the experienced users suggest. You'll get even more crap! (Rails devs are notorious for this).

My point is, when in Rome, do things as the Romans.

What may be true for one language, may not be true for another. In this case, our suggestion of using Visual Studio would have helped out.

You could have used a diff tool and checked what changed when you ticked a "gui control" you despise so much. :P
Was This Post Helpful? 0
  • +
  • -

#23 AdamSpeight2008  Icon User is online

  • MrCupOfT
  • member icon


Reputation: 1997
  • View blog
  • Posts: 8,804
  • Joined: 29-May 08

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 09:30 PM

I feel insulted, just because my prefer language is vb.net that I'm stupid. (Example: Take note Line 10 is a recursive Lambda Function) I'm a poly-linguistic programer, object-oriented, functional (not an expert like Raynes) ARM assembly and C++.

I think 5650 Kudos Points;- Consisting of 62 Tutorials (some with over 74000 views), 100+ Snippets, (one snippet has had over 8000views), 1300+ Reputation Points and the Mentor Badge.

Would strongly counter your argument.

Quote

You need to learn how to better educate people in computer science and properly answer there specific questions so that they may learn.


ssandro
Contributions diddly squat.

Learning about compiler flags isn't going to help learn C# only how to compile it.

Now I really wish I could retract that rep point I gave you for the Information in Post 17.




And by the way
Spoiler

This post has been edited by AdamSpeight2008: 05 April 2012 - 09:39 PM

Was This Post Helpful? 0
  • +
  • -

#24 ssandro  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 05-April 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 09:38 PM

Ok, I will take your advice and try VS more, but as I said it is very overwhelming. I am not used to that type of enbironment. In VS I find it hard to find all the code that was written for me (I know I keep bringing this up, bit for example when I make a form I cannot find that "header" file where that form is actually coded - and i know in c sharp there is no header...but you know what i mean haha).
Also, merely out of curiosity, how do you guys feel about sharpdev? I always have an affinity for open source software and I didn't know if it was any worse to use sharpdev than VS.
Was This Post Helpful? 0
  • +
  • -

#25 ssandro  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 05-April 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 09:46 PM

Ok ok! I don't want to make any enemies or anything. I am really sorry I just got frustrated that I had this little annoying thing going on any nobody was addressing it but was instead trying to make me stop using a text editor. Right off the bat I said I would probably move to VS soon, I just felt like I learned how the libraries worked and everything when I wrote them in there myself. It's those little things that really help me into a language, and the fact that VS has them in there automatically at the beginning annoyed me. I really am thankful though that you guys are giving me the advice to use VS, it could definitely come in use later on in the field.
Was This Post Helpful? 0
  • +
  • -

#26 AdamSpeight2008  Icon User is online

  • MrCupOfT
  • member icon


Reputation: 1997
  • View blog
  • Posts: 8,804
  • Joined: 29-May 08

Re: C# Beginner Question - Blank Console Appearing?

Posted 05 April 2012 - 10:11 PM

Visual C# 2010 Express Edition

You have to remember there are different SKU of VS, the express edition are the most basic of them. You didn't need the full capability of the full versions of VS to learn the language. If do feel you want them you can upgrade from inside the express edition.

Best feature of the VS IDE has to be the Intellisense, VS11 has added Javascript and C++ support to it as well.
In vb.net if you add the xml schemea for a xml file to the project, you'll even get Intellisense support over the XML. (Video)

The IDE is there to help to be productive, one button click to compile and run your project.
Was This Post Helpful? 0
  • +
  • -

#27 fullyunknown  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 44
  • Joined: 23-March 12

Re: C# Beginner Question - Blank Console Appearing?

Posted 07 April 2012 - 08:36 AM

View Postssandro, on 05 April 2012 - 08:00 PM, said:

I have solved the problem! I found this on a tutorial and will post it so that anyone with the same problem as me can also fix it. Who would have thought it had to do with my compile command?

"To produce Windows Applications, the C# CSC compiler has a '/t:WinExe' (/target:WinExe) option. Always remember to use this switch when compiling your final WinForm application.
You might have many times seen WinForm applications (mostly the samples which install with the .NET SDK) with a Ms-Dos windows behind them and wondering, Why does the Ms-Dos window behind GUI applications appear??
Well the answer to this question has already been answered, if you don't use the '/t:WinExe' compiler options then the compiler produces a normal Console Application which has a Ms-Dos window. "


I had the same issue, I knew how to make it a application only through IDE itself, but was looking how to do it through command prompt. Finally, after a whole bunch of google searches and no results, turned to this form and found your post, and your answer.
csc /t:winexe filename.cs


Thanks so much.. :bananaman:
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2