Catch "Output window" text in an external console app

Hi, I was wondering if/how it is possible to catch the debug text from visual studio debugger (in the "output window") from an external console app when the visual studio is not attached. I would like to use this on test environments that does not have visual studio installed to be able to see the same debug output from visual studio with a custom-made app.

Thanks
LVL 3
MikeDotNet555Asked:
Who is Participating?
 
abelConnect With a Mentor Commented:
About MDBG: your chances will be much higher if you ask that in a new question. I for one have never used it.

On the exception handler: that's quite easy. You have to bind to the UnhandledException event and the ThreadException event. It is explained in good detail here: http://www.switchonthecode.com/tutorials/csharp-tutorial-dealing-with-unhandled-exceptions

-- Abel --
0
 
abelCommented:
The easiest thing to do is to use a tool that can already do that for you: DebugView. It uses a sophisticated hooking mechanism to be able to do just a bit more than you would be able to do yourself. But it is simple to use and you can instruct your users to use it too: http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
0
 
abelCommented:
Alternatively, if you are interested in doing this yourself, there's also an open source project that does about the same thing, but then as a plugin for VS. I don't think it uses the kernel mode hook, but that's not needed for usermode applications anyway. You can see how the technique works by browsing the source: http://vsdbgview.codeplex.com/
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
MikeDotNet555Author Commented:
That program seem nice but it dosent seem to catch anything at all. Any idea? maby .NET debug output is different?
0
 
MikeDotNet555Author Commented:
edit: I think I might have been misunderstood, I could probably catch the debug output using Debug.Writeline but the "Debug output" on visual studio write alot of stuff like exceptions, loaded libs, console.write ouput, etc.. I would like to be able to catch all those informations withing a separate app.
0
 
abelCommented:
All that extra information is unfortunately only available when you are running inside the IDE. That info gets lost when you run the application outside of the IDE, unless you attach the IDE as a debugger (and unless you still have the debug information in your app). All you can catch are Debug.WriteLine statements....

What many people usually end up doing is writing a global error handler and logging those errors to some external source (using log4net or similar, which can do all that for you and more). Then, don't forget to rethrow the error (just use "throw", no params) so that the normal termination of the application can take place.
0
 
MikeDotNet555Author Commented:
ok 2 questions:

1. Would there be an example of writing such global error handler?

2. I am currently using a program called MDBG (http://msdn.microsoft.com/en-us/library/ms229861.aspx) but the program is that the documentation is really obscure and it is not quite easy to use. Right now I made a tiny debugger that I can attach to my processes but it is really unstable and after some time it either crash or make the debugged app crash. Does anyone have more information/examples about the usage of MDBG or similar tools? I know that catching the "Output" is possible and I don't mind attaching a custom-made debugger, but I am clearly having troubles with this one and it's chaotic documentation.

Thanks for your answers so far I think that DebugView might come in handy later on.
0
 
MikeDotNet555Author Commented:
Thanks, unfortunately I did not had the time yet to check MDBG yet but I think this is what I will use when/if I have the time because documentation of MDBG is not really good and I think it would take quite some time to get everything working correctly.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.