Need param names and values programmtically

row118

Member
Joined
Feb 4, 2006
Messages
21
Programming Experience
5-10
Im building an error routine that will give me the variable names and the values in the faulty sub or function.

VB.NET:
Public Class myParamInfo
  public paramName as string 
  public paramValue as String 
  paramType as string
End Class

Calling Code:


VB.NET:
Dim stFrame As New StackFrame
Dim currentMethod As System.Reflection.MethodBase = stFrame.GetMethod()
Dim currentParameters() As System.Reflection.ParameterInfo = currentMethod.GetParameters()
Dim prmArgument As ParameterInfo
dim argList as New ArrayList
Try 
   stuff
catch ex as exception
   For each prmArgument in currentParameters 
     dim oparaminfo as New myParamInfo
     oparaminfo.paramName = prmArgument.name
     oParaminfo.paramValue =  ?
     oParamInfo.paramtype= prmArgument.ParameterType.tostring
     arrgList.add(oParamINfo)
   Next prmArgument
   DoCustomErrorStuff(argList)
End Try

PrmArgument returns the variable name, not the value. How do i get the value or is there a better way to do this?

Thanks
 
parameterinfo includes order, name, data type, and other stuff not including the actual value

I know you can get its default value, and whether or not it is an input value etc, but I don't think you can get a dynamic value from it..

could be wrong
 

Latest posts

Back
Top