internal object InvokeMethod_Internal(object instance, string method, params object[] args)
{
SetError();
object[] ar;
if (args == null || args.Length == 0)
ar = new object[0];
else
{
ar = new object[args.Length];
for (int i = 0; i < args.Length; i++)
{
ar[i] = FixupParameter(args[i]);
}
}
object result = null;
try
{
if(method.Contains(".") || method.Contains("["))
result = ReflectionUtils.CallMethodEx(instance, method, ar);
else
result = ReflectionUtils.CallMethodCom(instance, method, ar);
}
catch (Exception ex)
{
SetError(ex.GetBaseException(), true);
throw ex.GetBaseException();
}
// Update ComValue parameters to support ByRef Parameters
for (int i = 0; i < ar.Length; i++)
{
if (args[i] is ComValue)
((ComValue) args[i]).Value = FixupReturnValue(ar[i]);
}
return FixupReturnValue(result);
}