public override void CallAsFunction(int methodNumber, IValue[] arguments, out IValue retValue) { var method = _methods[methodNumber]; if (!(method.IsFunction ?? true)) { throw RuntimeException.UseProcAsAFunction(); } var dispId = method.DispatchId; try { try { var result = DispatchUtility.Invoke(Instance, dispId, MarshalArguments(arguments)); retValue = CreateIValue(result); } catch (System.Reflection.TargetInvocationException e) { throw e.InnerException ?? e; } } catch (System.MissingMemberException) { throw RuntimeException.MethodNotFoundException(method.Name); } }