Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Gain access to a property with reflection
Message
De
05/02/2013 09:12:43
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Gain access to a property with reflection
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01565141
Message ID:
01565141
Vues:
74
I am using reflection to execute a method. When that method returns false, I would like to gain access to a property.

Here is the method using used to call the other method:
    Public Function Operation() As Boolean
        Dim lnOperation As Integer = 1
        Dim loOperation As Operation = New Operation(oProcess)
        Dim loOperationMethodInfo As System.Reflection.MethodInfo = Nothing
        Dim loOperationType As Type = loOperation.GetType()
        Dim loOperationParameter(0) As Object

        ' Get the operation ID
        lnOperation = Val(oProcess.GetProcess("Operation"))

        ' Define the parameter
        loOperationParameter(0) = False

        ' Use reflection to dynamically access the method
        loOperationMethodInfo = loOperationType.GetMethod("Operation" + lnOperation.ToString)

        ' Call the method
        If Not loOperationMethodInfo.Invoke(loOperation, loOperationParameter) Then
            Throw New System.Exception(loOperationMethodInfo.cMessage)
        End If

        Return True
    End Function
The Throw line, as is, cannot work, because the designer cannot recognized the cMessage property. Basically, the message is "'cMessage' is not a member of 'System.Reflection.MethodInfo'." This is normal. I would just like to know how to make this cMessage property available here.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform