HighTechTalks DotNet Forums  

How to obtain argument values in runtime?

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss How to obtain argument values in runtime? in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default How to obtain argument values in runtime? - 07-07-2003 , 07:55 AM






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

Reply With Quote
  #2  
Old   
AT
 
Posts: n/a

Default RE: How to obtain argument values in runtime? - 07-07-2003 , 06:01 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

--------------------
Quote:
From: mensikd (AT) seznam (DOT) 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 (AT) posting (DOT) 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 (AT) google (DOT) com
NNTP-Posting-Date: 7 Jul 2003 11:55:52 GMT
Path:
cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.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
Quote:
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.



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.