Main Site Documentation

See current method


Do you know any way to see current method name?

I know this two options, but they are for Framework:

MethodBase method = (new StackTrace(true)).GetFrame(0).GetMethod();
string methodname = method.DeclaringType.FullName + "." + method.Name;
MethodBase method = MethodInfo.GetCurrentMethod();
string methodname = method.DeclaringType.FullName + "." + method.Name;

Any idea about how to do it in Micro Framework?


There is another way, but neither works in Micro Framework:

using System.Diagnostics;
// get call stack
StackTrace stackTrace = new StackTrace();
// get calling method name


I’m pretty sure method names aren’t even included in the compiled code you deploy to the board (you are running on a small device). The same is true for Enum value names.


if we connect the the device using MFDeploy and exception occurs don’t we get any method names??