Printing the stack trace is not so difficult when using System.Diagnostics
. I am wondering if it is possible to print the VALUES of the parameters passed to each method up the stack trace, and if not why not.
Here is my preliminary code:
public static class CallStackTracker
{
public static void Print()
{
var st = new StackTrace();
for (int i = 0; i < st.FrameCount; i++)
{
var frame = st.GetFrame(i);
var mb = frame.GetMethod();
var parameters = mb.GetParameters();
foreach (var p in parameters)
{
// Stuff probably goes here, but is there another way?
}
}
}
}
Thanks in advance.