Accessing StackFrame

  • Thread starter Thread starter Juan Dent
  • Start date Start date
J

Juan Dent

Hi,

I recently discovered that it is possible to write a
tracing utility that will figure out the currently
executing method using StackFrame or StackTrace. These
classes provide the MethodInfo instance that describes the
currently executing method and of course that provides the
parameter information as well.

This is all very nice, because it automates tracing but I
have not found how to obtain the arguments' values in such
a generic form - i.e. via reflection.

It would be so powerful if we could obtain these values as
well in order that tracing includes even more valuable
debugging information.

For instance if I had:

class M
{
public static void Do(int i)
{
}
}

I can now find trace entering Do but not obtain the value
for the parameter i. Of course I could access its value by
name but that misses my objective: a generic method that
is able to obtain from the stack the currently executing
method and all information regarding it. It seems to me
this should be accesible some how.

Any ideas?
Juan Dent
 
Back
Top