mercredi 15 juin 2016

Reflection in VB.net

I need to get the class object and check a methods if the method is present in that class then it execute that method. the code is working in c# using (object) not in vb.net

Friend CallingObject As Object

Private Function GetCallUpdateMethod(ByRef KeyField As String, ByRef sqlstring() As String)
    Dim UpdateMethod = CallingObject.GetType().GetMethod("UpdateAuthorizedData")

    If UpdateMethod <> Nothing Then
        Dim parametersArray(0) As Object

        ReDim Preserve parametersArray(parametersArray.Length)
        parametersArray(parametersArray.Length - 1) = KeyField

        ReDim Preserve parametersArray(parametersArray.Length)
        parametersArray(parametersArray.Length - 1) = sqlstring

        UpdateMethod.Invoke(CallingObject, parametersArray)
    End If

End Function

Here CallingObject is always return the Object type is not showing the my assign object class type.





Aucun commentaire:

Enregistrer un commentaire