internal static object PrivateInvoke(RealProxy rp, IMessage msg, out Exception exc, out object[] out_args) { MonoMethodMessage monoMethodMessage = (MonoMethodMessage)msg; monoMethodMessage.LogicalCallContext = CallContext.CreateLogicalCallContext(true); CallType callType = monoMethodMessage.CallType; bool flag = rp is RemotingProxy; out_args = null; IMethodReturnMessage methodReturnMessage = null; if (callType == CallType.BeginInvoke) { monoMethodMessage.AsyncResult.CallMessage = monoMethodMessage; } if (callType == CallType.EndInvoke) { methodReturnMessage = (IMethodReturnMessage)monoMethodMessage.AsyncResult.EndInvoke(); } if (monoMethodMessage.MethodBase.IsConstructor) { if (flag) { methodReturnMessage = (IMethodReturnMessage)(rp as RemotingProxy).ActivateRemoteObject((IMethodMessage)msg); } else { msg = new ConstructionCall(rp.GetProxiedType()); } } if (methodReturnMessage == null) { bool flag2 = false; try { methodReturnMessage = (IMethodReturnMessage)rp.Invoke(msg); } catch (Exception e) { flag2 = true; if (callType != CallType.BeginInvoke) { throw; } monoMethodMessage.AsyncResult.SyncProcessMessage(new ReturnMessage(e, msg as IMethodCallMessage)); methodReturnMessage = new ReturnMessage(null, null, 0, null, msg as IMethodCallMessage); } if (!flag && callType == CallType.BeginInvoke && !flag2) { IMessage ret = monoMethodMessage.AsyncResult.SyncProcessMessage(methodReturnMessage); out_args = methodReturnMessage.OutArgs; methodReturnMessage = new ReturnMessage(ret, null, 0, null, methodReturnMessage as IMethodCallMessage); } } if (methodReturnMessage.LogicalCallContext != null && methodReturnMessage.LogicalCallContext.HasInfo) { CallContext.UpdateCurrentCallContext(methodReturnMessage.LogicalCallContext); } exc = methodReturnMessage.Exception; if (exc != null) { out_args = null; throw exc.FixRemotingException(); } if (methodReturnMessage is IConstructionReturnMessage) { if (out_args == null) { out_args = methodReturnMessage.OutArgs; } } else if (monoMethodMessage.CallType != CallType.BeginInvoke) { if (monoMethodMessage.CallType == CallType.Sync) { out_args = RealProxy.ProcessResponse(methodReturnMessage, monoMethodMessage); } else if (monoMethodMessage.CallType == CallType.EndInvoke) { out_args = RealProxy.ProcessResponse(methodReturnMessage, monoMethodMessage.AsyncResult.CallMessage); } else if (out_args == null) { out_args = methodReturnMessage.OutArgs; } } return(methodReturnMessage.ReturnValue); }