System.Runtime.Remoting.RemotingServices.ExecuteMessage C# (CSharp) Méthode

ExecuteMessage() private méthode

private ExecuteMessage ( MarshalByRefObject target, IMethodCallMessage reqMsg ) : IMethodReturnMessage
target System.MarshalByRefObject
reqMsg IMethodCallMessage
Résultat IMethodReturnMessage
        public static IMethodReturnMessage ExecuteMessage(MarshalByRefObject target, 
                                                          IMethodCallMessage reqMsg)
        {
            // Argument validation
            if(null == target)
            {
                throw new ArgumentNullException("target");
            }

            RealProxy rp = GetRealProxy(target);

            // Check for context match
            if( rp is RemotingProxy
                &&  !rp.DoContextsMatch() )
            {
                throw new RemotingException(
                    Environment.GetResourceString("Remoting_Proxy_WrongContext"));
            }
            
            // Dispatch the message
            StackBuilderSink dispatcher = new StackBuilderSink(target);

            // dispatch the message
            IMethodReturnMessage retMsg = (IMethodReturnMessage)dispatcher.SyncProcessMessage(reqMsg, 0, true);         
            
            return retMsg;
        } // ExecuteMessage

Usage Example

Exemple #1
0
        } // ComRedirectionProxy

        public virtual IMessage SyncProcessMessage(IMessage msg)
        {
            IMethodCallMessage   mcmReqMsg = (IMethodCallMessage)msg;
            IMethodReturnMessage replyMsg  = null;

            replyMsg = RemotingServices.ExecuteMessage(_comObject, mcmReqMsg);

            if (replyMsg != null)
            {
                // If an "RPC server not available" (HRESULT=0x800706BA) COM
                //   exception is thrown, we will try to recreate the object once.
                const int    RPC_S_SERVER_UNAVAILABLE = unchecked ((int)0x800706BA);
                const int    RPC_S_CALL_FAILED_DNE    = unchecked ((int)0x800706BF);
                COMException comException             = replyMsg.Exception as COMException;
                if ((comException != null) &&
                    ((comException._HResult == RPC_S_SERVER_UNAVAILABLE) ||
                     (comException._HResult == RPC_S_CALL_FAILED_DNE)))
                {
                    _comObject = (MarshalByRefObject)Activator.CreateInstance(_serverType, true);

                    replyMsg = RemotingServices.ExecuteMessage(_comObject, mcmReqMsg);
                }
            }

            return(replyMsg);
        } // SyncProcessMessage
All Usage Examples Of System.Runtime.Remoting.RemotingServices::ExecuteMessage
RemotingServices