|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Getting method parameters values at runtimeHello,
Is it possible to get access to method parameters values at runtime, without referencing them directly? I am working on a universal error logging for my application. I can easily obtain class and method names using the StackFrame object but it also would be nice to know parameters values of the method where an exception occurred. There must be a way to do this. Visual Studio "Call Stack" window displays this information. Tomasz Tom Jastrzebski <oegweb@nospam.nospam> wrote:
> Is it possible to get access to method parameters values at runtime, without No, there's no way of getting at the parameter values with reflection > referencing them directly? > I am working on a universal error logging for my application. I can easily > obtain class and method names using the StackFrame object but it also would > be nice to know parameters values of the method where an exception occurred. etc. > There must be a way to do this. Visual Studio "Call Stack" window displays Yes, but that's hooked into the debugger. If you looked at the > this information. debugging APIs you might be able to get the information from that - but I expect you don't really want to run under the debugger in production... -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too Thanks for the answer.
Could you give me some hint on those debugging APIs? Where do I look? I may want to try this approach but only in global error handler. When the app is about to crush anyway I no longer care about the performance. Tomasz Tomasz Jastrzebski <oegweb@nospam.nospam> wrote:
> Thanks for the answer. Well, I suspect you'll find it's not nearly as simple as that - and > > Could you give me some hint on those debugging APIs? Where do I look? > I may want to try this approach but only in global error handler. When the > app is about to crush anyway I no longer care about the performance. that if the debugger isn't attached when the method starts, it may well not be able to get the parameters of the method while it's running. To be honest, I don't know anything about the debugging APIs - I'd have to do the same kind of Google searches you'd have to. Still, a Google search for "debugging API .NET" gets lots of likely-looking hits... -- Jon Skeet - <sk***@pobox.com> http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet If replying to the group, please do not mail me too |
|||||||||||||||||||||||