HELP: how to get values of function arguments at run time (.NET reflection) ?

  • Thread starter Thread starter Marco
  • Start date Start date
M

Marco

Hi all


I am using .NET reflection to examine a stack trace, using the StackTrace,
StackFrame, MethodInfo, ParameterInfo and FieldInfo classes.

I can easily discover all methods in the call chain and discover their
parameter names and types.

What I would like to do is also know the values that were passed to the
method parameters for the current instance. I would think this should be
possible, because that info must be somewhere in the stack trace, right ?

I felt I was getting somewhere by using the FieldInfo.GetValue() method, but
I just can't seem to get it to work. It looks like the GetValue method only
gets values for class properties and such, but not function parameters.

Does anyone have any tips ?

Thanx !
 
Marco said:
I am using .NET reflection to examine a stack trace, using the
StackTrace, StackFrame, MethodInfo, ParameterInfo and FieldInfo
classes.

I can easily discover all methods in the call chain and discover
their parameter names and types.

What I would like to do is also know the values that were passed to
the method parameters for the current instance. I would think this
should be possible, because that info must be somewhere in the stack
trace, right ?

I felt I was getting somewhere by using the FieldInfo.GetValue()
method, but I just can't seem to get it to work. It looks like the
GetValue method only gets values for class properties and such, but
not function parameters.

Does anyone have any tips ?

(AFAIK) this is only possible when using a debugger.
 
Back
Top