Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter Values in Stack Walk

Status
Not open for further replies.

Hexonx

Programmer
Jan 10, 2001
102
US
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:
Code:
StackTrace trace = new StackTrace();
for(int i = 0; i < trace.FrameCount; i++)
{
	StackFrame fr = trace.GetFrame(i);
	MethodBase mt = fr.GetMethod();
					
	Debug.WriteLine(&quot;Parameters for &quot; + 
        mt.Name + &quot;: &quot;);

	ParameterInfo[] pis = mt.GetParameters(;
	foreach(ParameterInfo pi in pis)
	{
		Debug.WriteLine(&quot; - &quot; + pi.Name + &quot;:&quot;                + pi.ParameterType.ToString();
	}
}
As you can see, the parameters can be obtained, but I don't see a way to get the current value.

Any ideas?
 
I don't see a way of getting that info -- you can access the DefaultValue property of the ParameterInfo array elements, but not the actual value.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top