Is there a C# class for tracking service method calls like a stack trace

I know that there is of course a stack trace for keeping track of calls to methods within your program however it does not show a call to a method in a service as part of the trace. Is there any built in functionality in .NET to recognise when a call is made to a WCF service and then store the name of the called method?

For example we have the method below:

private void DoStuff()
    object  =  Service.ServiceMethodCall();

On the stack trace that I see I can recover the name of DoStuff() and other details but not the ServiceMethodCall(). I don't want to simply hard code the name of this method into my output. There has to be a better way.



If you are trying to diagnose problems in WCF, you can use the built-in WCF tracing functionality, which we have found to be indispensable for this. To do this (assuming WCF hosted in IIS), add the following to web.config:

      <source name="System.ServiceModel"
              switchValue="Information, ActivityTracing"
          <add name="traceListener"
              initializeData="c:\log\WebTrace.svclog"  />

If you are debugging and have VS Ultimate 2010, you could also use IntelliTrace.

Finally, if you are just trying to trace the source of exceptions that occur, dumping the StackTrace in the exception will show you the source of the error, assuming that the WCF service call is the only method in the chain that contains an exception handler. Our development practices mandate that, unless there are extraordinary, documented circumstances, only the outermost call (i.e. the WCF service entry) will contain an exception handler. This provides a significant reduction in the amount of time required to diagnose and fix bugs.


It appears that System.Runtime.Reflection.GetCurrentMethod may provide the information you are looking for.

Need Your Help

AS3 Retrieving a file from FZip

actionscript-3 action flash-cs5 zipfile

I am currently coding a game and I am storing all external files in a zip file to save space.

ADO.NET proper INSERT of data

c# table insert sql-server-ce

I am using a SQL CE 3.5 database in my C# project.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.