Main Site Documentation

See current method


#1

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?


#2

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

using System.Diagnostics;
// get call stack
StackTrace stackTrace = new StackTrace();
// get calling method name
Console.WriteLine(stackTrace.GetFrame(1).GetMethod().Name);

#3

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.


#4

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