Check out StackTrace and StackFrame classes in System.Diagnostics.
Beware of inlining, however, which may result in fewer stack frames than
you expect. Also, collecting stack frame information isn't the fastest
thing in the world, especially if you ship .PDBs and you want line and
file information too.