By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,980 Members | 877 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,980 IT Pros & Developers. It's quick & easy.

Getting the parameters passed to a function and log them

P: n/a

Hi,

I have been asked this before but I think that I didn't explain myself well

I am using exception and logging and I would like to log the parameters
which was passed to the function
whenever an exception was occurred,again,I want to emphasize that I am the
owner of the code.

I can see that idlasm can view the content of an assembly so I wonder why my
logging module cannot
use reflection to get the function signature and than poll the passed
parameters from the stack

Another option I can think of is to create an exception class which hold an
array of parameters and values.
a function which throw an exception can fill this array
so I can logged it

BTW:It can be done with _penter in C++
(http://www.johnpanzer.com/aci_cuj/)

Thanks in advance.


Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

You can get the signature of the method using StackFrame.GetMethod, but as
far as getting the actual values of the parameters I don't think it's
possible, I believe it has to do with the complexity of the reference types.

IIRC this was asked like two weeks ago, so you may look in google.
Cheers,

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

"Julia" <co********@012.net.il> wrote in message
news:es*************@TK2MSFTNGP09.phx.gbl...

Hi,

I have been asked this before but I think that I didn't explain myself
well

I am using exception and logging and I would like to log the parameters
which was passed to the function
whenever an exception was occurred,again,I want to emphasize that I am
the
owner of the code.

I can see that idlasm can view the content of an assembly so I wonder why
my
logging module cannot
use reflection to get the function signature and than poll the passed
parameters from the stack

Another option I can think of is to create an exception class which hold
an
array of parameters and values.
a function which throw an exception can fill this array
so I can logged it

BTW:It can be done with _penter in C++
(http://www.johnpanzer.com/aci_cuj/)

Thanks in advance.

Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.