473,789 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.prin tln. 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 2401
It does indeed

Console.WriteLi ne("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.Diagnost ics 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.WriteLin e("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.FileS tream fsLog = new System.IO.FileS tream("C:\Log\a pplog.txt",
System.IO.FileM ode.OpenOrCreat e);
TextWriterTrace Listener listener = new TextWriterTrace Listener(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.goo gle.com...
Hi All

Java has a facility where you can send output to a DOS window using
System.out.prin tln. 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*********@la ndstar.com> wrote in message news:<OE******* *******@TK2MSFT NGP11.phx.gbl>. ..
The framework has two good classes for what you are trying to accomplish in
the System.Diagnost ics 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.WriteLin e("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.FileS tream fsLog = new System.IO.FileS tream("C:\Log\a pplog.txt",
System.IO.FileM ode.OpenOrCreat e);
TextWriterTrace Listener listener = new TextWriterTrace Listener(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.goo gle.com...
Hi All

Java has a facility where you can send output to a DOS window using
System.out.prin tln. 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
22036
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 using the Console.Write command. The question is how can I see the outputs in the client machine ? Is there a specific programm to do it or Can I use the prompt window ?
1
3708
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 window open without having to put Console.ReadLine() statements in my code? Regards John L
1
4808
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 single-pane form GUI. I've got some stdout print statements in the code ... but I cannot find where in the world the output text is appearing. For printing I tried both: printf ("Hello world\n"); and Console::Write ("Hello World\n");
1
1182
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 displayed in a window - either a dos window or a 'proper' window with a text field etc... I can easily create a window with a text field, but I can't find any way to attach it to my project so I can write to it from there (I'm looking to just...
2
7671
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 starts, you type a command it does a command and returns a message. I thought I would be able to consume it in my C# app by using the Process.StandardInput in conjunction with the Process.StartInfo.RedirectStandardOutput. The output works fine and I...
3
13860
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 application is run in Debug mode. However, I just can't get that to work. I'm using Visual Studio 2005. I've confirmed that my application is compiled as a console application, and that I'm running in Debug mode. To investigate this issue, I've reduced...
6
3462
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 tried Console.Clear but, this results in an error.
3
6568
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 in the "View"- FYI, the text in the "View"->"Output" window is below instead: 'IO.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL
1
8370
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 (Not Trace or Debug classes) 2. Set up the trace solution in the application's application.config file 3. Use Visual Basic.NET to test the trace 4. Test the TraceSource using Visual Studio.NET 2005 IDE "Windows application" rather than with...
0
9663
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10404
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10195
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10136
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.