Question

Is it possible in C# to see the traces in a separate console. For example, I am having a window based application in which there are trace statements that will write the currently executed method name in to the console. When I run this application, it should automatically open a console and start the traces. Is this possible?

Was it helpful?

Solution

If you set the project type of your window application to Console, it will open a console window when you run it.

OTHER TIPS

You can create a console window by calling the Win32 AllocConsole API through P/Invoke.

http://pinvoke.net/default.aspx/kernel32/AllocConsole.html

I think you are looking for a TraceListener class. (another link)

In .NET you use a TraceListener to listen to your own trace message. And then you can print them out in a form with textbox or a console window.

Listeners can also be configured via app.config if my memory serves me right. That's so you could debug deployed applications.

I'd recommend dbgview.exe from Sysinternals. It allows you to capture your trace output and save it to file (among other features).

You can get it from http://live.sysinternals.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top