Parameters value

  • Thread starter Thread starter Giojo
  • Start date Start date
G

Giojo

Hi to 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?

I'm sure It's possible because Visual studio in Debub mode, in local
window shows the name and the value of all params..
I want to make a trace function WriteMethodInfo that takes all params
for logging..

public void FunName(type1 param1, type2 param2...)

SLDebug.WriteMethodInfo(param1, param2...);
//I would write "SLDebug.WriteMethodInfo();" but I don't know how
WriteMethodInfo()
//could take params from the stack!
try
{
Do something...
}
catch (Exception ex)
{
throw ExceptionManager.LogException(ex);
}



Thanks!!
Giojo
 
Giojo,

You can't get the value of the parameters through reflection. This is
because reflection only knows about types as they are at compile time.

The debugger gets the values of the parameters through debugging
interfaces in the CLR. You could theoretically hook into the same
interfaces, but you REALLY don't want to do that, as it will slow down your
process tremendously.

You are going to have to pass your parameter values into your routine
which does the logging.

Hope this helps.
 
Back
Top