473,461 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get Current Method's parameter values as collection with reflection(?)

Hi y'all .. I hope this is an interesting one ...

Within an executing method, I can call MethodBase.GetCurrentMethod() and
retrieve info about the method that's currently running, including parameter
names & data types.

Is there a way to get the parameter v a l u e s as well ??? ( I know ...
this is indeed weird, but .. don't ask :D )
Cheers,
Angel
O:]
Jul 21 '05 #1
3 13552
Hi,

I don't know for sure if you can get it, a good start point may be
StackFrame class, the parameters are stored in the stack so this may be the
start point.

Please if you find the answer post it back here.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Angelos Karantzalis" <ak**********@yahoo.com> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Hi y'all .. I hope this is an interesting one ...

Within an executing method, I can call MethodBase.GetCurrentMethod() and
retrieve info about the method that's currently running, including
parameter
names & data types.

Is there a way to get the parameter v a l u e s as well ??? ( I know ...
this is indeed weird, but .. don't ask :D )
Cheers,
Angel
O:]

Jul 21 '05 #2
I'm afraid that after an extensive search on the web, it seems that the only
way to retrieve parameter values at runtime is by using Debugging API's.
Pitty ...
O:(
"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:#j**************@TK2MSFTNGP10.phx.gbl...
Hi,

I don't know for sure if you can get it, a good start point may be
StackFrame class, the parameters are stored in the stack so this may be the start point.

Please if you find the answer post it back here.

Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Angelos Karantzalis" <ak**********@yahoo.com> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Hi y'all .. I hope this is an interesting one ...

Within an executing method, I can call MethodBase.GetCurrentMethod() and
retrieve info about the method that's currently running, including
parameter
names & data types.

Is there a way to get the parameter v a l u e s as well ??? ( I know .... this is indeed weird, but .. don't ask :D )
Cheers,
Angel
O:]


Jul 21 '05 #3
Angelos,

No, you can not. You can only reflect on metadata, which is created a
compile time. To that end, you would have to pass the actual values
yourself to whatever method you wish.

Now, one might think that it would be easy to get the values (and
indeed, it might be because you have access to the stack). However, it
wouldn't be a good idea, because there is no way to make anything "const",
which is needed so that you don't modify anything further up on the stack.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Angelos Karantzalis" <ak**********@yahoo.com> wrote in message
news:e1**************@tk2msftngp13.phx.gbl...
Hi y'all .. I hope this is an interesting one ...

Within an executing method, I can call MethodBase.GetCurrentMethod() and
retrieve info about the method that's currently running, including
parameter
names & data types.

Is there a way to get the parameter v a l u e s as well ??? ( I know ...
this is indeed weird, but .. don't ask :D )
Cheers,
Angel
O:]

Jul 21 '05 #4

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

Similar topics

2
by: Marcin | last post by:
Hello! Is there any method to detect parameters values passed to called method? For example: public Guid ApplicationLogin(string userName, string password, int dbId)
2
by: Mad Scientist Jr | last post by:
Is it possible to write a method with a signature for x parameters (so you get intellisense when you call it), but from within the method, be able to access the parameter names and values in a...
7
by: Brad Quinn | last post by:
Is there a way to get the values of the paramaters to a method programatically? I know that I can use reflection to find out the parameter names and types, etc., but I want to know the values...
3
by: Angelos Karantzalis | last post by:
Hi y'all .. I hope this is an interesting one ... Within an executing method, I can call MethodBase.GetCurrentMethod() and retrieve info about the method that's currently running, including...
4
by: Alex Stevens | last post by:
Hi All, I'm writing a data access class in which I expose an SQlClient.SQLCommand's Parameters Collection via a property. How would I go about overloading the parameters.add method with one of...
2
by: Jeff | last post by:
I am trying to dynamically load an assembly via reflection and then invoke a method of that assembly that will populate a custom type collection passed into the method byref. I am able to...
1
by: kplkumar | last post by:
I am trying to get the method and the parameters passed to that method from the stackTrace. My code is, private void GetExecutingMethodInfo() { StackTrace trace = new StackTrace(false); ...
2
by: ME | last post by:
How would one obtain the parameter VALUES of a method that has already run? I can find the method using the StackTrace and StackFrame classes but once I find the method I would like to obtain the...
2
by: gman | last post by:
How can you get the current class of a method? We are writting out trace error messages using the System.Reflection.MethodBase.GetCurrentMethod to get the Current Method but a string is passed...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
1
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.