Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get ParameterInfo Value? [duplicate]

I am using the below code to get Calling Method name and its parameter inside a method.

var stackTrace = new StackTrace();
var methodName = stackTrace.GetFrame(1).GetMethod().Name;
var parameters = stackTrace.GetFrame(1).GetMethod().GetParameters();

foreach (var parameterInfo in parameters)
{
    var name = parameterInfo.Name;
    var value = "How to get value?";
}

Now my question is to get the value of that parameter. Any ideas?

like image 685
Hary Avatar asked Feb 27 '13 10:02

Hary


1 Answers

There is no easy way of doing that. The only working approach I've seen is adding code to your application that will attach external debugger to itself and read stack information. John Robbins is showing this is his book using modified sources of MDBG.

like image 67
Sergey Rybalkin Avatar answered Oct 23 '22 21:10

Sergey Rybalkin