473,394 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Sending output to a console window in Windows App

Hi All

Java has a facility where you can send output to a DOS window using
System.out.println. This is useful while developing as you can see
what it going in your code.

Does .Net provide a similar facility? I notice that when a Windows app
runs there is an output window that contains messages from the
compiler etc. Is it possible to 'plug' into this?

Any help would be appreciated..

Regards

Paul Bowman
Nov 15 '05 #1
3 2376
It does indeed

Console.WriteLine("Hello World");

If you run a windows program the output will be sent to the "Output"
window in Visual Studio

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #2
The framework has two good classes for what you are trying to accomplish in
the System.Diagnostics namespace:

o Trace - if you want to continue to produce trace statements in production
o Debug - if you only need debugging information while in development and do
not want that code executed in production.

Using them is simple. For example: "Trace.WriteLine("In Load_Form");" will
write "In Load_Form" to the output window in VS. In addition to uncondional
write statements there are also conditional methods, such as WriteLineIf,
Assert.

What is neat about the classes is that you can also hook up a listener to
record the tracing information in a text file or the event log. You could
control, if a permanent trace is written to file by a configuration setting
in the app.config file and thereby build tracing tools into production apps
that you can turn on and off.

To write all Trace.WriteLine message to a text file you only need the
following code:

System.IO.FileStream fsLog = new System.IO.FileStream("C:\Log\applog.txt",
System.IO.FileMode.OpenOrCreate);
TextWriterTraceListener listener = new TextWriterTraceListener(fsLog);
Trace.Listeners.Add(listener);

You might have to control how often the information is written to disk, you
pretty much have two choices for that. Either manually flushing or
autoflushing to disk. To manually flush the log out, use Trace.Flush() or
automate it with Trace.AutoFlush = true;

If you want more information about it I would recommend looking into the
MCAD/MCSD certification books. I really like them since for an experienced
programmer that is jumping into .NET they have a nice pace compared to the
21 day books.

Hope this helps

Robert Sentgerath

"Paul Bowman" <pa**************@yahoo.co.uk> wrote in message
news:ff**************************@posting.google.c om...
Hi All

Java has a facility where you can send output to a DOS window using
System.out.println. This is useful while developing as you can see
what it going in your code.

Does .Net provide a similar facility? I notice that when a Windows app
runs there is an output window that contains messages from the
compiler etc. Is it possible to 'plug' into this?

Any help would be appreciated..

Regards

Paul Bowman

Nov 15 '05 #3
Thanks Guys!! - Just what I wanted!

Regards Paul Bowman

"Robert Sentgerath" <rs*********@landstar.com> wrote in message news:<OE**************@TK2MSFTNGP11.phx.gbl>...
The framework has two good classes for what you are trying to accomplish in
the System.Diagnostics namespace:

o Trace - if you want to continue to produce trace statements in production
o Debug - if you only need debugging information while in development and do
not want that code executed in production.

Using them is simple. For example: "Trace.WriteLine("In Load_Form");" will
write "In Load_Form" to the output window in VS. In addition to uncondional
write statements there are also conditional methods, such as WriteLineIf,
Assert.

What is neat about the classes is that you can also hook up a listener to
record the tracing information in a text file or the event log. You could
control, if a permanent trace is written to file by a configuration setting
in the app.config file and thereby build tracing tools into production apps
that you can turn on and off.

To write all Trace.WriteLine message to a text file you only need the
following code:

System.IO.FileStream fsLog = new System.IO.FileStream("C:\Log\applog.txt",
System.IO.FileMode.OpenOrCreate);
TextWriterTraceListener listener = new TextWriterTraceListener(fsLog);
Trace.Listeners.Add(listener);

You might have to control how often the information is written to disk, you
pretty much have two choices for that. Either manually flushing or
autoflushing to disk. To manually flush the log out, use Trace.Flush() or
automate it with Trace.AutoFlush = true;

If you want more information about it I would recommend looking into the
MCAD/MCSD certification books. I really like them since for an experienced
programmer that is jumping into .NET they have a nice pace compared to the
21 day books.

Hope this helps

Robert Sentgerath

"Paul Bowman" <pa**************@yahoo.co.uk> wrote in message
news:ff**************************@posting.google.c om...
Hi All

Java has a facility where you can send output to a DOS window using
System.out.println. This is useful while developing as you can see
what it going in your code.

Does .Net provide a similar facility? I notice that when a Windows app
runs there is an output window that contains messages from the
compiler etc. Is it possible to 'plug' into this?

Any help would be appreciated..

Regards

Paul Bowman

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Boba | last post by:
Hi, I'm programming a WinForm application. I would like to enter commands that will send output that will help me to locate bugs in the future. I know that there is a way to send output by...
1
by: gemel | last post by:
I am debugging code that writes to the console window, I select an appropriate line and the select 'Run to Cursor'. The console output does appear and then the window closes. How can I keep this...
1
by: noleander | last post by:
Hi. I've got a C++ program written in Visual C++ 2003. The program is trivial, created with the Program-creation wizard: used the .NET "Form" template. The program has a trivial...
1
by: royzeb | last post by:
Hi, I've got a simple vc++ program that basically just runs a daemon in the background and sends update messages to a logfile as it goes along. What I'd like to do is see these log messages also...
2
by: nautonnier | last post by:
Hello, I have a C# app that spawns several processes each containing a console app written by another developer in C++. The console app was written first to be just like a console app: it...
3
by: TC | last post by:
I'm trying to debug a console application, but I can't see the console output. I've seen many references which say that console output is supposed to appear on the Output window when the...
6
by: =?Utf-8?B?R3JlZw==?= | last post by:
I am using the following command to output my results to the Output window (for testing things out). Console.WriteLine ("Output") I'd like to clear the Output window of any previous output. I...
3
by: Curious | last post by:
I''ve created a simple Console Application in C#.NET (.NET 2.0), and I have the following code: Console.WriteLine("Now let us begin!"); However, the string, "Now let us begin!", never shows up...
1
by: mquincey | last post by:
One of the features offered by .NET 2.0 is the use of the TraceSource class. In an attempt to demonstrate its use, I wanted to run my test under the following conditions: 1. Use TraceSource class...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.