Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Array and Reflection
Message
 
To
10/12/2006 18:33:50
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01176405
Message ID:
01176759
Views:
11
Sure you can. Look at the InnerException of the returned Exception. Somewhere in the Exception stack is the real error...

Most likely it's:

You're calling a method that has overloads (in which case you have to pass the parameter types as a type array)
You don't have permissions to access the method
The object returned is null in your code <s>


+++ Rick ---


>>Are there different overloads for this method? If so Reflection requires some additional code to ensure you get the right signature of rhte method you are calling.
>
>The signature is somewhat generic. I have a table Task.dbf which contains, among other fields, a class and a method fields. Then, the robot uses this method to do the call:
>
>
>    ' expO1 Data provider
>    Private Function ProcessTaskQuery(ByVal toDataProvider As Framework.Framework.Data) As Boolean
>        Dim lcClass As String = ""
>        Dim lcMethod As String = ""
>        Dim lnCounter As Integer = 0
>        Dim loClass As Type = Nothing
>        Dim loClassMethodInfo As System.Reflection.MethodInfo = Nothing
>        Dim loClassObject As Object = Nothing
>        Dim loClassType As Type = Nothing
>        Dim loParameterClass(1) As Object
>        Dim loParameterMethod(0) As Object
>        Dim loRow As DataRow
>        loParameterClass(0) = oApp
>        loParameterClass(1) = Me
>        loParameterMethod(0) = False
>        For lnCounter = 0 To toDataProvider.nCount - 1
>            loRow = toDataProvider.oDataSet.Tables("Temp").Rows(lnCounter)
>            Status.Text = "Processing " + Trim(loRow("Title")) + "..."
>            lcClass = Trim(loRow("Class"))
>            lcMethod = Trim(loRow("Method"))
>            Try
>                loClass = Type.GetType("Robot." + lcClass)
>                loClassObject = Activator.CreateInstance(loClass, loParameterClass)
>                loClassType = loClassObject.GetType()
>                loClassMethodInfo = loClassType.GetMethod(lcMethod)
>                loClassMethodInfo.Invoke(loClassObject, loParameterMethod)
>            Catch loError As Exception
>                oApp.ErrorSetup(loError)
>                Return False
>            End Try
>        Next
>        Return True
>    End Function
>
>
>So, instantiating the class and calling the method like this might explain why I was never able to get the proper error message but a generic one. See the below response in the other paragraph for the details.
>
>>You might want to check the actual error message fired by the reflection method call.
>
>That is one problem. Whenever I have an error occuring under the reflection hierarchy, I cannot get the proper error message but a generic error message which is always the same. This goes back to a thread I started several months ago. I never received a follow up on it by anyone so I didn't resolve that issue since then. So, when this is happening, it is really difficult to find the real place of the error and takes longer to debug.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform