Console.WriteLine Not Available

  • Thread starter Thread starter Jeff S
  • Start date Start date
J

Jeff S

Whenever I execute any Console commands (Console.WriteLine "yada yada
yada"), the console does not appear. It doesn't even flash by.

I want to be able to use Console commands. Any ideas?

I'm running VS.NET 2003 on XP pro/SP1.
 
You need to have created a Console Application, when you create your
project. You can change the type of project by going into your project's
properties.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
 
Jeff S said:
Whenever I execute any Console commands (Console.WriteLine "yada
yada yada"), the console does not appear. It doesn't even flash
by.

I want to be able to use Console commands. Any ideas?

I'm running VS.NET 2003 on XP pro/SP1.

Did you choose "console application" as the project type? (see project's
properties)
 
Whenever I execute any Console commands (Console.WriteLine "yada yada
yada"), the console does not appear. It doesn't even flash by.

Look in the IDE's internal console (Output window) If it's not a console
application your developing it will appear in the debugger.

Nick.
 
Okay, the console window will appear for me if I'm working in a console
application.

So, does this mean that all those code snippets in online documentation that
include [Console.WriteLine] ALL assume that the user is developing a console
application? It just seems odd to me that there would be hundreds of code
snippets that make this assumption without telling the reader. Am I missing
something?

honestly wondering...
 
I have the same thoughts like you Jeff

It appears in the IDE's output window. If your that bothered, why not make
your own console form (simply a multiline textbox) that displays debugging
information?

Nick.
 
Hi Jeff,

|| So, does this mean that all those code snippets
|| in online documentation that include [Console.
|| WriteLine] ALL assume that the user is
|| developing a console application?

Yep.

This is your first console app? You fell down. You found out.
You'll never not know again.

You're only ignorant until you learn. And this lesson's early on
the path.

But, yes, it is confusing for those first few steps.

Best wishes,
Fergus
 
Or, you could actually call an unmanaged API, AllocConsole to display the
console window, then it should work from a Windows Form, however, this is
dangerous because you need to call FreeConsole when you are done, or when
you close the Console window, your app will terminate.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit
 
Hello,

Jeff S said:
So, does this mean that all those code snippets in online
documentation that include [Console.WriteLine] ALL assume
that the user is developing a console application? It just seems
odd to me that there would be hundreds of code snippets that
make this assumption without telling the reader. Am I missing
something?

honestly wondering...

Yes -- you need a console application project or compile using vbc.exe with
"/target:exe".

HTH,
Herfried K. Wagner
 
Hello,

Nak said:
It appears in the IDE's output window. If your that bothered, why not make
your own console form (simply a multiline textbox) that displays debugging
information?

Why not use a Console Application?!

Regards,
Herfried K. Wagner
 
Why not use a Console Application?!

More to the point, "Why use a console application?", it's not always
convenient to have a console in the background simply for debugging
purposes, I only temporarily write the the console when I am debugging a
certain line of code, when I'm not my application contains practially no
debugging code.

Nick.
 
Hello,

Nak said:
More to the point, "Why use a console application?", it's not always
convenient to have a console in the background simply for debugging
purposes, I only temporarily write the the console when I am debugging a
certain line of code, when I'm not my application contains practially no
debugging code.

For debugging purposes I use Debug.WriteLine.

Regards,
Herfried K. Wagner
 
For debugging purposes I use Debug.WriteLine.

"Simple fact is, that if I knew there was a debug.writeline I wouldn't have
just said what I said"

:-)

Nick.
 
Jeff,
Remember all those code snippets are example code snippets.

They are examples of how to use the methods. Not reusable code snippets per
se.

The intent I'm sure is: You look at the example, see how it works, apply it
to your application.

If they had code snippets for each type of app, you would need (including,
but not limited to) :
Windows Forms
Web Forms
Web Services
Windows Services
Console Application
Class Library (for each of the above)
Class Library (for none of the above)
Other

Code snippets for each function...

Hope this helps
Jay

Jeff S said:
Okay, the console window will appear for me if I'm working in a console
application.

So, does this mean that all those code snippets in online documentation that
include [Console.WriteLine] ALL assume that the user is developing a console
application? It just seems odd to me that there would be hundreds of code
snippets that make this assumption without telling the reader. Am I missing
something?

honestly wondering...



Herfried K. Wagner said:
Hello,



Are you sure you created a project of type "Console Application"? If you
want to create a new console from within a Windows Forms project, you can
use the AllocConsole PInvoke call:
http://www.google.com/groups?as_q=AllocConsole&as_ugroup=microsoft.public.do
tnet.*

HTH,
Herfried K. Wagner
 
Nick,
There is both Debug.WriteLine & Trace.WriteLine.

Be sure to check out both classes in help they also have Assert, Fail,
Indent, Unindent, Write, WriteIf, & WriteLineIf methods.

The major difference between the two is that Debug will normally be
'removed' from your source for Release builds, while Trace will remain.

Both classes also support being configured via the app.config file, allowing
you to change where the output is going. This is accomplished via
TraceListener classes. The default is the output window in the debugger, you
can change it to be a text file or the Windows event log.

The following articles may explain further:
http://msdn.microsoft.com/msdnmag/issues/01/07/vbnet/default.aspx


Hope this helps
Jay
 
Both classes also support being configured via the app.config file,
allowing
you to change where the output is going. This is accomplished via
TraceListener classes. The default is the output window in the debugger, you
can change it to be a text file or the Windows event log.

I'm thinking of looking into this "app.config file" I presume that it is
just an easy way of storing the applications settings etc.? But then again,
I prefer using the registry and per user settings, could the config file
benefit over this?

Cheers for the info also.

Nick.
 
Hi Jay,

|| Be sure to check out both classes in help they also
|| have Assert, <Fail>, Indent, Unindent, Write, WriteIf,
|| & WriteLineIf methods.

Fail? I'm using that all the time, or so the compiler keeps
telling me. Funny though, I've never asked for it..

Regards,
Fergus
 
Back
Top