StackTrace ss = new StackTrace(true);
StackFrame[] stackArr = ss.GetFrames();
StringBuilder sb = new StringBuilder();
foreach (StackFrame frame in stackArr)
{
sb.AppendFormat("Module :{0}\r\n", frame.GetMethod().Module.Name);
sb.AppendFormat("Type :{0}\r\n", frame.GetMethod().MemberType.ToString());
sb.AppendFormat("Name :{0} \r\n", frame.GetMethod().Name);
sb.AppendFormat("LineNo :{0} \r\n\r\n", frame.GetFileLineNumber().ToString());
}
string str = sb.ToString();
MessageBox.Show(str);
呵呵, 有了上面的代码,有时候调试起来就方便多了。