2

can any one tell me how to find the source code line using byte offset (from stack trace) in wp7?

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
Lydia
  • 145
  • 1
  • 10

1 Answers1

0

This is something Ive used but its not win phone specific - but it might work for you with some tweeking:

private static string lineAndMethod() {
    int stack_frame_depth = 5;
    StackFrame sf = new StackFrame(stack_frame_depth, true);
    while (sf.GetFileName() == null && stack_frame_depth > 0)
    sf = new StackFrame(--stack_frame_depth, true);
    if (sf.GetFileName() == null) // Failed.
        return "";
    MethodBase mb_caller = sf.GetMethod();
    retrun string.Format("{0}, {1}: {2}]",
                         Path.GetFileName(sf.GetFileName()),
                         mb_caller.Name, sf.GetFileLineNumber());
}
Ricibob
  • 7,505
  • 5
  • 46
  • 65