""Jeffrey Tan[MSFT]"" <jetan@online.microsoft.com> wrote in message
news:Y$rEIQ91GHA.4280@TK2MSFTNGXA01.phx.gbl...
> Hi Semedao,
>
> Trace class is designed as a utility class to help us write tracing
> information to the customized pipe. However, it does contains the power of
> stack walking or method tracing.
>
> Net provided StackTrace&StackFrame classes for us to do the stack walking
> work. Also you may use Reflection API, MethodInfo.GetCurrentMethod or
> MethodBase.GetCurrentMethod static methods to get the current executing
> method. Please refer to the article below for more information about the
> customize usage of these classes:
> "TraceListeners and Reflection"
>
http://www.codeproject.com/csharp/customtracelistener.asp >
> However, if you just want to get the stack trace of the current execting
> code, my experience told me that the simplest way is using
> System.Environment.StackTrace proeprty. This property internally
> encapsulate StackTrace&StackFrame classes to get the stack. You may give
> it
> a try.
>
> Finally, there is no build-in support for tracing method calling in .Net.
> This is because tracing each methods will have a lot influence over
> performance. If you really want to get trace function in .Net code, we may
> use .Net Profiling API to get this done. The Profiling API provides a lot
> of hooking notifications for us, in which the method entry and exit
> notifcation is what we are interested in. You may leverage this
> notification to implement a trace library on your own. Please refer to the
> 2 articles below for more information about method entry and exit
> notification in .Net Profiling API:
> "Receiving Method Entry and Exit Notifications" section in "The .NET
> Profiling API and the DNProfiler Tool"
>
http://msdn.microsoft.com/msdnmag/issues/01/12/hood/ > "Using the Profiling API Enter/Leave Function Hooks "
>
http://blogs.msdn.com/jkeljo/archive/2005/08/11/450506.aspx >
> Additionally, John Robbins uses .Net Profiling API to create a managed
> exception monitor library in "Chapter 10: Managed Exception Monitoring" of
> his wonderful book "Debugging Applications for Microsoft .NET and
> Microsoft
> Windows".
>
> Hope this helps.
>
> Best regards,
> Jeffrey Tan
> Microsoft Online Community Support
> ==================================================
> Get notification to my posts through email? Please refer to
>
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif > ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
>
http://msdn.microsoft.com/subscriptions/support/default.aspx. > ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>