Geeks With Blogs

News

Series

Add to Technorati Favorites


An Archived Managed World This blog has moved to http://www.managed-world.com/blog

[Crosspost from Managed World]

Well, after downloading Beta 2 of Visual C# Express Edition 2005, it didn't take long for me to come across my first annoyance.

The first thing I did was to create a new Console Application to mess around with the new features of the Console class (which happen to be pretty cool darnit). In .NET 2.0 you can now place text anywhere on the Console, change the background and foreground colors, programatically change the cursor position, etc. Basically, you can now achieve Curses-like development (not quite, but sort of) using the new Console class. You can just go ahead and check out Heroic Adventure by Chris Williams to see an example of it in action.

So, what was my annoyance? It was the fact that I wrote some simple code that didn't work:

Console.CursorVisible = false;

Console.Clear();
Console.SetCursorPosition(12, 12);
Console.ForegroundColor = ConsoleColor.Cyan;
Console.Write("A B C ");
Console.ForegroundColor = ConsoleColor.Red;
Console.Write("1 2 3 ");

Console.Read();

I was eagerly awaiting for this to run to see my new baby in all its beauty and glory (aka Ugly Programmer Art). So, what was I greeted with when I hit F5 to see this baby run in the debugger? Well, I was greeted with a nice and warm "IOException: Handle Is Invalid." Oh baby, that wasn't intuitive. So what the heck was going on here?

I changed the code to do a simple Console.WriteLine() and found that the output in Debug mode was not to the Console window as I expected, but was to this "Quick Console" window in Visual Studio. How nice, huh? So, when running under the debugger, my Console was not the Console I wanted to use.

Luckily, it was an easy fix. What happened (at least for me), is that when VC# Express was installed, there is an IDE option called "Redirect all console output to the Quick Console window" that was checked by default. To fix this, all I did was uncheck this box (Tools -> Options -> Debugging -> General).

What is slightly more annoying is that this is a breaking change if you have legacy Console applications that you wish to debug, I believe. If I recall correctly, this is a new option/feature that was introduced in 2005 and is not present in VS2003 (at least it's not in the same place in my installation at work).

So, even though you created a Console Application, it will not behave like a Console application did in 2003 in Debug mode until you un-check this checkbox. Far from being intuitive I say. I'm just laying this out there in case anyone else comes across this.

Now, onward ho!

Posted on Thursday, November 3, 2005 9:54 PM | Back to top


Comments on this post: VC# Express Annoyance #1 - Debugging A Console Application

# re: VC# Express Annoyance #1 - Debugging A Console Application
Requesting Gravatar...
Worse, you'll get this exception if your console output is redirected to file, like from commandline: MyApp.exe > log.txt
Left by anony on Jul 12, 2010 3:23 PM

Your comment:
 (will show your gravatar)


Copyright © Jason Olson | Powered by: GeeksWithBlogs.net