>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>
I have simplified it like this. It no longer passes parameters to the method and it is much faster.
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 loAssembly As System.Reflection.Assembly
Dim loMethod As System.Reflection.MethodInfo
Dim loObject As Object
Dim loParameterClass(1) As Object
Dim loRow As DataRow
Dim loType As System.Type
loParameterClass(0) = oApp
loParameterClass(1) = Me
loAssembly = System.Reflection.Assembly.LoadFrom(oApp.cStartupDirectory + "Robot.exe")
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
loType = loAssembly.GetType("Robot." + lcClass)
loObject = Activator.CreateInstance(loType, loParameterClass)
loMethod = loObject.GetType().GetMethod(lcMethod)
loMethod.Invoke(loObject, Nothing)
Catch loError As Exception
oApp.ErrorSetup(loError)
Return False
End Try
Next
Return True
End Function
However, when I have an error in one of the methods called, I still have a generic error message:
"Exception has been thrown by the target of an invocation."
The stack is as followed:
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Robot.Main.ProcessTaskQuery(Data toDataProvider)
There isn't much there to help me in the stack information.
There is no overload in this design. As for the permissions, I do not know what you mean. If there is no error in the method, the code executes ok. But, if there is an error, do you mean I need to setup permission somewhere as this design would require it in order for me to obtain relevant information on the error? As for the object returned is null, this is usually when the object cannot be created. In this case, all the objects are properly created.