Groups | Blog | Home
all groups > dotnet framework > may 2006 >

dotnet framework : Detect if compiling as a console application



Michael D. Ober
5/19/2006 11:50:05 AM

Is there anyway the VB Compiler can detect if a program is a console
application? I have some libraries that need to write to the console if
the program is a console app.

Thanks,
Mike Ober.


Chris Dunaway
5/19/2006 1:47:45 PM
can't you just call System.Console.WriteLine("") anyway? If the app is
a console app, the line will be written to it, otherwise they will not.
Snozz
5/19/2006 7:14:56 PM
What Chris describes is my experience. I use it alot for throwing
stuff to console that helps me debug. There is a noticable performance
hit though, and I wonder, if the console is not enabled, and a
Console.WriteLine call is made, what happens? Is there some sort of
buffer or resource that the text still writes to? I've never tested
the performance of writing to console when there is no console, as I
only do this when compiled as DEBUG, using conditional compilation
statements.
AddThis Social Bookmark Button