How to get parameter values from StackTrace, MethodBase?

  • Thread starter Thread starter Hardy Wang
  • Start date Start date
H

Hardy Wang

Hi all:
I have a logging class, which is used to log errors automatically. With
StackFrame.GetMethod().GetParameters() function, I am able to read all
parameter information except the real paramter value from ParameterInfo
class.
is there a way I can read real parameter values?


Thanks!!
 
Hardy,

As you shouldn't, as the ParameterInfo class represents the parameter,
not the call itself. It is the call that contains the values of the
parameter. It's kind of like saying why doesn't the MethodInfo class tell
you what the return value is (not the type, but the value)?

It would be nice if there was a GetParameterValues method on the
StackFrame instance, which would take a ParameterInfo instance and then
return the value in that parameter.

If you want to get this information, you have to pass the values to your
logging object somehow.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top