How to get parameter values from StackTrace, MethodBase?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hardy Wang

    #1

    How to get parameter values from StackTrace, MethodBase?

    Hi all:
    I have a logging class, which is used to log errors automatically. With
    StackFrame.GetM ethod().GetPara meters() function, I am able to read all
    parameter information except the real paramter value from ParameterInfo
    class.
    is there a way I can read real parameter values?


    Thanks!!

    --
    WWW: http://hardywang.1accesshost.com
    ICQ: 3359839
    yours Hardy


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: How to get parameter values from StackTrace, MethodBase?

    Hardy,

    As you shouldn't, as the ParameterInfo class represents the parameter,
    not the call itself. It is the call that contains the values of the
    parameter. It's kind of like saying why doesn't the MethodInfo class tell
    you what the return value is (not the type, but the value)?

    It would be nice if there was a GetParameterVal ues method on the
    StackFrame instance, which would take a ParameterInfo instance and then
    return the value in that parameter.

    If you want to get this information, you have to pass the values to your
    logging object somehow.

    Hope this helps.

    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com

    "Hardy Wang" <hardy_wang@mar ketrend.com> wrote in message
    news:e8nm88rfDH A.2328@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Hi all:
    > I have a logging class, which is used to log errors automatically.[/color]
    With[color=blue]
    > StackFrame.GetM ethod().GetPara meters() function, I am able to read all
    > parameter information except the real paramter value from ParameterInfo
    > class.
    > is there a way I can read real parameter values?
    >
    >
    > Thanks!!
    >
    > --
    > WWW: http://hardywang.1accesshost.com
    > ICQ: 3359839
    > yours Hardy
    >
    >[/color]


    Comment

    Working...