1

I have implemented a CustomTraceListener for use with Enterprise Library 5. From the TraceData method, I need to crawl the stack up 6 levels to my class that had the actual logging call, I need a property from there. I don't think I want a StackFrame climb because that only gets the class and not the object, right? What is the best way to get at the (string) property I need?

This is on Framework 4.0, thanks.

Snowy
  • 5,942
  • 19
  • 65
  • 119

1 Answers1

0

I don't think you can get (parameters) values from the .NET stack from the program itself, only methods, properties, classes, ie: anything that comes from .NET metadata.

If you want values, here are a some solutions:

  • instrument your code before compilation, adding lines of code to capture parameters values
  • instrument your code after compilation, with things like PostSharp for example (disclaimer: I'm not affiliated in any way)
  • write a .NET profiler, but this must be an external program. There a existing tools that do this already, like this one: CLR profiler. Version 4 of the CLR profiler (available here) comes with the source.
Simon Mourier
  • 132,049
  • 21
  • 248
  • 298