473,657 Members | 2,851 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HELP: how to get values of function arguments at run time (.NET reflection) ?

Hi all
I am using .NET reflection to examine a stack trace, using the StackTrace,
StackFrame, MethodInfo, ParameterInfo and FieldInfo classes.

I can easily discover all methods in the call chain and discover their
parameter names and types.

What I would like to do is also know the values that were passed to the
method parameters for the current instance. I would think this should be
possible, because that info must be somewhere in the stack trace, right ?

I felt I was getting somewhere by using the FieldInfo.GetVa lue() method, but
I just can't seem to get it to work. It looks like the GetValue method only
gets values for class properties and such, but not function parameters.

Does anyone have any tips ?

Thanx !
Nov 20 '05 #1
1 1994
"Marco" <Ma***@bla.co m> schrieb

I am using .NET reflection to examine a stack trace, using the
StackTrace, StackFrame, MethodInfo, ParameterInfo and FieldInfo
classes.

I can easily discover all methods in the call chain and discover
their parameter names and types.

What I would like to do is also know the values that were passed to
the method parameters for the current instance. I would think this
should be possible, because that info must be somewhere in the stack
trace, right ?

I felt I was getting somewhere by using the FieldInfo.GetVa lue()
method, but I just can't seem to get it to work. It looks like the
GetValue method only gets values for class properties and such, but
not function parameters.

Does anyone have any tips ?


(AFAIK) this is only possible when using a debugger.
--
Armin

http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1823
by: EsC | last post by:
Hy! is it possible to pass function-arguments by reference? (for example in PHP you can use the "&" operator ... ) thx iolo
25
2382
by: Steven Bethard | last post by:
So I end up writing code like this a fair bit: map = {} for key, value in sequence: map.setdefault(key, ).append(value) This code basically constructs a one-to-many mapping -- each value that a key occurs with is stored in the list for that key. This code's fine, and seems pretty simple, but thanks to generator
7
3299
by: Amit Sharma | last post by:
Hi, I wanted to know when we call function with argument, Does the arguments stored in stack always or it compiler specific and could be stored in queue e.g. Does this program's output depends upon the compiler specific or always would be b a #include<stdio.h>
2
1422
by: xideum | last post by:
Hi. Question: In a function that takes multiple arguments, each with a default value setis there anyway to either alter the order of the parameters you pass to it or skip the passing of certain parameters? I'm mainly asking because lately I've had to do some gui programming, calling a widget function that takes like 80 defaulted arguments, with only a single one I want to alter, makes me hate life. Sorry if there's recently been a...
21
4107
by: dragoncoder | last post by:
Consider the following code. #include <stdio.h> int main() { int i =1; printf("%d ,%d ,%d\n",i,++i,i++); return 0; }
0
1275
by: IR | last post by:
Hi, I'm trying to store values of an enum type in a std::bitset container, in a contiguous manner. eg. typedef enum { meValue1 = 0xbaad, meValue2 = 0xbeef,
0
938
by: Steve Holden | last post by:
pierre-yves guido wrote: Your English is quite good. In future, though, please try to make your subject line say a bit more about the problem - we *all* need help! When you define a function or a method (using the def statement) you can specify default values for arguments. A simple example: ... return a*b ... 9
2
1328
by: svlsr2000 | last post by:
Why are function arguements pushed into stack and not heap or any registers. I know there may be a function which takes much more arguments then available registers:( Why can;t we use heap or some other memory to pass the function arguments?
8
1471
by: karthikbalaguru | last post by:
Hi, Is it possible to define default values for arguments that are not passed when the function call is made ? I tried it , but it showed linking errors. Any other ideas/help ? Thx in advans, Karthik Balaguru
4
1383
by: turnitup | last post by:
What's the easiest way to get the name of function arguments? For example function fred($day, $week) { echo (firstargumentname); echo (secondargumentname); }
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8723
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.