Friday, April 3, 2015

C# 콜스택 보기

    StackTrace stackTrace = new StackTrace();           // get call stack
    StackFrame[] stackFrames = stackTrace.GetFrames();  // get method calls (frames)
    // write call stack method names
    foreach (StackFrame stackFrame in stackFrames)
    {
     System.Reflection.MethodBase method = stackFrame.GetMethod();
     String strFrame = method.Name + " " + method.Module + " " + method.DeclaringType;
     Console.WriteLine(strFrame);   // write method name
    }


No comments:

Post a Comment