Obtain parameter values from method

  • Thread starter Thread starter ME
  • Start date Start date
M

ME

How would one obtain the parameter VALUES of a method that has already run?
I can find the method using the StackTrace and StackFrame classes but once I
find the method I would like to obtain the value of one of the parameters
that were passed to the method. Is this possible? Even if I have to use
PInvoke to do so?

I can currently find the parameter TYPEs using reflection but I can not
figure out to obtain the values.

Thanks,

Matt
 
ME said:
How would one obtain the parameter VALUES of a method that has already
run? I can find the method using the StackTrace and StackFrame classes but
once I find the method I would like to obtain the value of one of the
parameters that were passed to the method. Is this possible? Even if I
have to use PInvoke to do so?

I can currently find the parameter TYPEs using reflection but I can not
figure out to obtain the values.

What is the context here? Where is this method you're trying to get values
from?
 
The method is within the call stack of the current running process. It will
be in a different assembly (usually System.dll) I find it by itterating
through the call stack (using the StackTrace class and the StackFrame
class). Once I find the method the StackFrame class allows me to obtain a
MethodBase object that includes the method name various other properties
that describe the method, including the parameter types and names.

Here is an example of finding the Method via the above approach:
http://www.syncfusion.com/FAQ/WindowsForms/FAQ_c60c.aspx#q978q

Unfortunately though this does not include the actual VALUES of the
parameters that where passed into the method when it was called. To get an
idea of what I am trying to accomplish, simply view the Call Stack in Visual
Studio. There you will see what methods were called in your code and what
parameters wered passed to them (including the values). Hence, I believe
this is possible, I just do not know where to start to figure out how to do
it. For example, what are the rules of obtaining these values? Must the
application be in debug mode? Is there a way to use the windows API to
obtain the values?

Thanks,

Matt
 
Back
Top