Does anyone know how to get the values of parameters when walking a StackTrace? I'm working on an exception handling framework and want to extract parameter values as part of an "exception stack dump."
Here's my code so far:
As you can see, the parameters can be obtained, but I don't see a way to get the current value.
Any ideas?
Here's my code so far:
Code:
StackTrace trace = new StackTrace();
for(int i = 0; i < trace.FrameCount; i++)
{
StackFrame fr = trace.GetFrame(i);
MethodBase mt = fr.GetMethod();
Debug.WriteLine("Parameters for " +
mt.Name + ": ");
ParameterInfo[] pis = mt.GetParameters(;
foreach(ParameterInfo pi in pis)
{
Debug.WriteLine(" - " + pi.Name + ":" + pi.ParameterType.ToString();
}
}
Any ideas?