示例#1
0
        public virtual IMessage SyncProcessMessage(IMessage msgRequest)
        {
            IMessage result = null;

            try
            {
                byte[] array  = null;
                byte[] array2 = null;
                CADMethodReturnMessage retmsg = null;
                CADMethodCallMessage   cadmethodCallMessage = CADMethodCallMessage.Create(msgRequest);
                if (cadmethodCallMessage == null)
                {
                    MemoryStream memoryStream = CADSerializer.SerializeMessage(msgRequest);
                    array2 = memoryStream.GetBuffer();
                }
                Context currentContext = Thread.CurrentContext;
                try
                {
                    CrossAppDomainSink.ProcessMessageRes processMessageRes = (CrossAppDomainSink.ProcessMessageRes)AppDomain.InvokeInDomainByID(this._domainID, CrossAppDomainSink.processMessageMethod, null, new object[]
                    {
                        array2,
                        cadmethodCallMessage
                    });
                    array  = processMessageRes.arrResponse;
                    retmsg = processMessageRes.cadMrm;
                }
                finally
                {
                    AppDomain.InternalSetContext(currentContext);
                }
                if (array != null)
                {
                    MemoryStream mem = new MemoryStream(array);
                    result = CADSerializer.DeserializeMessage(mem, msgRequest as IMethodCallMessage);
                }
                else
                {
                    result = new MethodResponse(msgRequest as IMethodCallMessage, retmsg);
                }
            }
            catch (Exception e)
            {
                try
                {
                    result = new ReturnMessage(e, msgRequest as IMethodCallMessage);
                }
                catch (Exception)
                {
                }
            }
            return(result);
        }
示例#2
0
 private static CrossAppDomainSink.ProcessMessageRes ProcessMessageInDomain(byte[] arrRequest, CADMethodCallMessage cadMsg)
 {
     CrossAppDomainSink.ProcessMessageRes result = default(CrossAppDomainSink.ProcessMessageRes);
     try
     {
         AppDomain.CurrentDomain.ProcessMessageInDomain(arrRequest, cadMsg, out result.arrResponse, out result.cadMrm);
     }
     catch (Exception e)
     {
         IMessage msg = new MethodResponse(e, new ErrorMessage());
         result.arrResponse = CADSerializer.SerializeMessage(msg).GetBuffer();
     }
     return(result);
 }