Hello,
I have an issue understanding something using invoke
I have a shared method that take the following as parameters
pWindow as DesktopWindow, pSelectedEntity as User = nil, optional pEntitiesToLoad() as User = nil, optional pEntitiesToExclude() as User = nil, pFilters as Dictionary = nil
I have this method on different classes that I use and I want to invoke this method using introspection but I got illegalCastException regarding the 2 optional arrays
This code does not work
var tClass as Introspection.TypeInfo = GetTypeInfo(User)
if tClass<>nil then
var tMethods() as Introspection.MethodInfo = tClass.GetMethods()
for each tMethod as introspection.MethodInfo in tMethods
if tMethod.IsShared and tMethod.Name = "pick" then
var tParams() as introspection.ParameterInfo = tMethod.GetParameters()
var params() as Variant
params.Add(self)
params.add(nil)
params.add(nil)
params.add(nil)
params.add(nil)
tEntity=tMethod.Invoke(nil,params)
exit
end if
next
end if
If I replace some params by this, its working
var params() as Variant
params.Add(self)
params.add(nil)
var tArray(-1) as User
params.add(tArray)
params.add(tArray)
params.add(nil)
but if I replace the array declaration by:
var tArray(-1) as User
It does not work anymore.
I would like to have this code working regardless of the class that I use or is it an issue with introspection?
Thank you
3 posts - 2 participants