2

谁能告诉我如何在 wp7 中使用字节偏移(来自堆栈跟踪)找到源代码行?

4

1 回答 1

0

这是我用过的东西,但它不是特定于赢得手机的 - 但它可能对你有用:

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());
}
于 2012-05-11T08:24:42.110 回答