How to create dynamic parameters and pass to invoke a method using reflection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pso19
    New Member
    • Oct 2007
    • 1

    How to create dynamic parameters and pass to invoke a method using reflection

    Hi,

    I am trying to access all the properties, methods of an assembly using reflection. But what i want to do is invoke a method which contains custom parametrs like enumeration defined in a different assembly.

    For ex:

    Code:
     Dim assemblyToLoad As Assembly = Nothing
    
                assemblyToLoad = Assembly.LoadFrom(AssemblyName)
    
                Dim types As Type() = assemblyToLoad.GetTypes()
                Dim type1 As Type
    
                For Each type1 In types
                    If type1.IsClass And (String.Compare(type1.FullName, ClassName.Trim()) = 0) Then
    
                        Dim mi As MethodInfo() = type1.GetMethods()
                        Dim mi1 As MethodInfo
                        For Each mi1 In mi
                            If mi1.IsStatic Then
    
                                Dim ex As ParameterInfo
    
                             
                                For Each ex In CType(mi1, MethodInfo).GetParameters()
    
                                    Dim parameterType As String = ex.ParameterType.ToString()
                                    Dim parameterName As String = ex.Name.ToString()
    
    ' After knowing the parameter type to be for ex: NewAssembly.Class.Enum
    ' How i pass this type to invoke the methos??
    
                                Next
    
                            End If
    
                        Next
                        
                    End If
    
                Next
Working...