tags:

views:

123

answers:

2

exact duplicate:
http://stackoverflow.com/questions/559148/how-can-i-add-a-trace-to-every-method-call-in-c


Hi, I like to do tracing in my c# code. I don't like to add statements in each method to do it. Is there any way to use a method to do trace when rest of the methods in the application getting invoked at runtime.

Thanks, P.Gopalakrishnan.

A: 

If you use VS 2005 (and probably 2008, and maybe 2003), you can just add a tracepoint, similarly to the way you add breakpoints. You can then define what output you want when that method/code line is hit. It will only output those traces when run inside VS, but it might be a good way to start.

Noam Gal
A: 

If you have it available to you, the Profiler in Visual Studio will trace your method calls and provide a call tree etc.

Steven