Get the calling function name from the called function

.net, .net-3.5, c#, function

Solution

new StackFrame(1, true).GetMethod().Name

Note that in release builds the compiler might inline the method being called, in which case the above code would return the caller of the caller, so to be safe you should decorate your method with:

[MethodImpl(MethodImplOptions.NoInlining)]

Problem

Possible Duplicate: How can I find the method that called the current method? How can I get the calling function name from the called function in C#?

Original source

Related problems