There is no documented way for gaining access to the current stack like exists in .NET (like with StackFrame
).
You could try to maintain a log or record of the execution yourself by creating a function which records the operations. It would require a little bit of pasting into functions:
[Conditional("DEBUG")]
void Log(string message,
[CallerMemberName] string member = "",
[CallerFilePath] string path = "",
[CallerLineNumber] int line = 0 ) {
Debug.WriteLine(string.Format("{0}\t{1}:{3} ({2}) ",
message, member, path, line));
}
Using...
Log("hello!");
Would produce:
hello! MainPage_Loaded:45 (c:\Dev\Projects\Win8AppTest\MainPage.xaml.cs)
The above function uses several relatively recent attributes you can use. For example: CallerMemberName
. That function obtains the method or property name of the caller.
The Conditional
attribute just says to only compile the function in DEBUG builds.