You need to use the StackTrace class.
Snippet from MSDN
// skip the current frame, load source information if available
StackTrace st = new StackTrace(new StackFrame(1, true))
Console.WriteLine(" Stack trace built with next level frame: {0}",
st.ToString());
source
share