all groups > dotnet clr > july 2003 >
You're in the

dotnet clr

group:

How to obtain argument values in runtime?


How to obtain argument values in runtime? mensikd NO[at]SPAM seznam.cz
7/7/2003 4:55:52 AM
dotnet clr:
Hi,
can you please help me by obtaining methods argument values in
runtime? I have this construction:

--- source code ---
try
{
someobject.somemethod(someargumentvalue);
}
catch(Exception exc)
{
ShowStack(exc)
}

public static void ShowStack(Exception exc)
{
StakTrace loTrace = new StackTrace(exc,true);
StackFrame loFrame = loTrace.GetFrame(loTrace.FrameCount - 1);
...
//now I'm displaying some infos about function, in which exception
occured.
//everything is OK, but how can I got the values of methods
arguments?
}
--- source code ---

So question is: "When I can get function name, line number, parameters
name etc. but I can't get parameters value which were in stack frame
by raising exception. How can I get those values?

Thanks for advice,
RE: How to obtain argument values in runtime? simonhal.nospam NO[at]SPAM online.microsoft.com
7/7/2003 10:01:52 PM
David,

Currently, it is not possible to get the argument values from a StackFrame
object. In retail code, such values are mostly unavailable due to
optimizations by the JIT compiler (argument lifetime management and method
inlining are examples). Currently, the best way to accomplish this is to
run under a debugger and inspect the values of the arguments at exception
time, or to compile your assemblies as debuggable and attach a debugger
when an unhandled exception is thrown.

Cheers,
Simon

--------------------
[quoted text, click to view]
cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.sul.t-online.de!t-onlin
e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-01!sn-
xit-09!supernews.com!postnews1.google.com!not-for-mail
[quoted text, click to view]


--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
AddThis Social Bookmark Button