In the .Net Framework I have made a method for logging purposes in that the called method is able to determine who (what class/method) called it...
// Get Log Stage
string stage = "";
try
{
System.Diagnostics.StackFrame stackFrame;
System.Reflection.MethodBase stackFrameMethod;
string typeName;
stackFrame = new System.Diagnostics.StackFrame(1, true);
stackFrameMethod = stackFrame.GetMethod();
typeName = stackFrameMethod.ReflectedType.FullName;
if (typeName.Trim().Length == 0) typeName = "Unknown";
if (typeName.IndexOf(".") > -1)
{
typeName = typeName.Substring(typeName.LastIndexOf(".") + 1);
}
stage = typeName + ":" + stackFrameMethod.Name;
}
catch (Exception expTrace)
{
Debug.WriteLine("Could not obtain log stage from stack. " + expTrace.Message);
stage = "Unknown";
}
I noticed in the micro framework that System.Diagnostics does not contain the StackFrame class. Perhaps it was placed somewhere else? Perhaps there is another way a method can determine the calling method?
Drilling down to the StackFrame
Started by Bendage, Jan 26 2012 05:28 AM
2 replies to this topic
#1
Posted 26 January 2012 - 05:28 AM
#2
Posted 04 August 2012 - 03:35 PM
Hi Bendage,
Have you managed to find the solution to your above problem?
Care to shared?
Thanks in advance.
#3
Posted 09 August 2012 - 05:46 PM
Hi Bendage,
Have you managed to find the solution to your above problem?
Care to shared?
Thanks in advance.
Hi,
Unfortunately, the Micro Framework does not provide such methods. It is not currently possible.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users