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] >From: mensikd@seznam.cz (David Mensik)
>Newsgroups: microsoft.public.dotnet.framework.clr
>Subject: How to obtain argument values in runtime?
>Date: 7 Jul 2003 04:55:52 -0700
>Organization:
http://groups.google.com/ >Lines: 32
>Message-ID: <3e043eb8.0307070355.5f1a0c35@posting.google.com>
>NNTP-Posting-Host: 158.194.200.44
>Content-Type: text/plain; charset=ISO-8859-1
>Content-Transfer-Encoding: 8bit
>X-Trace: posting.google.com 1057578952 19918 127.0.0.1 (7 Jul 2003
11:55:52 GMT)
>X-Complaints-To: groups-abuse@google.com
>NNTP-Posting-Date: 7 Jul 2003 11:55:52 GMT
>Path:
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] >Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.clr:1350
>X-Tomcat-NG: microsoft.public.dotnet.framework.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,
> David Mensik
>
--
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.