Can I attach an External Debug Window to My Running Executable?

  • Thread starter Thread starter Charles Law
  • Start date Start date
C

Charles Law

Suppose my application is running on a client machine, and they report an
intermittent problem. It only occurs after the program has been running for
a while, and then occasionally fails to perform correctly.

I would like to be able to come along with a program I have written (or a
third-party program), load it onto the client machine - without stopping the
problem application - and attach to the application to receive trace
information in a window.

I can add any code needed to my application now, so that when this happens
in real life I am prepared.

Can this be done?

What code would I need to add to my application to make this possible?

How do I write a small program that can attach to my running application to
receive trace information for display in a window, or is there a third-party
tool?

TIA

Charles
 
Hi,

http://msdn.microsoft.com/library/d...debug/html/vctskAttachingToRunningProgram.asp

Ken
----------------------
Suppose my application is running on a client machine, and they report an
intermittent problem. It only occurs after the program has been running for
a while, and then occasionally fails to perform correctly.

I would like to be able to come along with a program I have written (or a
third-party program), load it onto the client machine - without stopping the
problem application - and attach to the application to receive trace
information in a window.

I can add any code needed to my application now, so that when this happens
in real life I am prepared.

Can this be done?

What code would I need to add to my application to make this possible?

How do I write a small program that can attach to my running application to
receive trace information for display in a window, or is there a third-party
tool?

TIA

Charles
 
Hi Ken

Thanks for the link. I just came across this actually, but the downside is
that it would seem that I have to have the development environment installed
on the client machine. Is that correct?

I am really looking for something quite simple. If I have Trace statements
in my code then the output goes to the Output window in the VS debugger. I
would like to receive those messages in an external program - perhaps one
that I have to write. Do you know if it can be done?

Charles
 
Hi,

Maybe this will help.
http://www.codeguru.com/vb/gen/vb_system/win32/article.php/c7525/

http://msdn.microsoft.com/msdnmag/issues/02/11/CLRDebugging/default.aspx

Ken
-------------------
Hi Ken

Thanks for the link. I just came across this actually, but the downside is
that it would seem that I have to have the development environment installed
on the client machine. Is that correct?

I am really looking for something quite simple. If I have Trace statements
in my code then the output goes to the Output window in the VS debugger. I
would like to receive those messages in an external program - perhaps one
that I have to write. Do you know if it can be done?

Charles
 
Hi Ken

The codeguru article looks like just the job. Thanks.

Charles
 
The following works with the standart output:

in your app.exe.config file add
<system.diagnostics>
<switches>
<add name="myTraceFlag1" value="0"/>
</switches>
</system.diagnostics>

When the customer have a problem, tell him to change the value, e.g
<add name="myTraceFlag" value="4"/>

value options:
0 none TraceSwitch is disabled.
1 TraceError: Only Errors.
2 TraceWarning: Errors and Warnings.
3 TraceInformation: Errors, Warnings, and Info.
4 TraceVerbose: All kinds of messages are traced.
No filter is applied.

' in your application add the following code:
Dim tl As New TextWriterTraceListener(System.Console.Out)
Trace.Listeners.Add(tl)

' Use Trace.WriteLineIf :
dim ts As New TraceSwitch("myTraceFlag1", "description")
Trace.WriteLineIf(ts.TraceInfo, myStrStatus)
Trace.WriteLineIf(ts.TraceWarning, myStrStatus)


Run your application using stdOutput:
myApp.exe > myWarnings.txt

and you will get your Trace lines in "myWarnings.txt" file

Atara
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top