internal object InvokeStaticMethod_Internal(string TypeName, string Method, params object[] args)
{
SetError();
Type type = GetTypeFromName(TypeName);
if (type == null)
{
SetError("Type is not loaded. Please make sure you call LoadAssembly first.");
return null;
}
// fix up all parameters
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]);
}
}
ErrorMessage = "";
object Result = null;
try
{
Result = type.InvokeMember(Method, BindingFlags.Static | BindingFlags.Public | BindingFlags.InvokeMethod, null, type, 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);
}