Inheritance: System.SystemException
Exemplo n.º 1
0
        [System.Security.SecurityCritical]  // auto-generated
        internal static Object DoCrossContextActivationCallback(Object[] args)
        {
            IConstructionCallMessage    reqMsg   = (IConstructionCallMessage) args[0]; 
            IConstructionReturnMessage  replyMsg = null;
                
            // call the first sink in the server context chain
            // <
            IMethodReturnMessage retMsg =  (IMethodReturnMessage) 
                    Thread.CurrentContext.GetServerContextChain().SyncProcessMessage(reqMsg);
        
            // The return message may not be of type
            // IConstructionReturnMessage if an exception happens
            // in the sink chains.
            Exception e = null;
            replyMsg = retMsg as IConstructionReturnMessage;
            if (null == replyMsg)
            {
                if (retMsg != null)
                {
                    e = retMsg.Exception;
                }
                else
                {
                    e = new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_Failed"));
        
                }
                replyMsg = new ConstructorReturnMessage(e,null); 
                // We have created our own message ... transfer the callcontext
                // from the request message.
                ((ConstructorReturnMessage)replyMsg).SetLogicalCallContext(
                        (LogicalCallContext)
                        reqMsg.Properties[Message.CallContextKey]);
            }

            return replyMsg;
        }
	        public override void AfterThrowing(RemotingException ex)
	        {
	            base.AfterThrowing(ex);
	            throw exception;
	        }
	        public virtual void AfterThrowing(RemotingException ex)
	        {
	            Count("RemotingException");
	        }
 public void AfterThrowing(RemotingException ex)
 {
 }
 public void AfterThrowing(
     MethodInfo method, object[] args, object target, RemotingException ex)
 {
 }
Exemplo n.º 6
0
        // This function is called by ActivationServices in case
        // the activation needs to be within the same appdomain. These
        // are only for ContextBound types.
        // It is also called to do satisfy remote incoming requests from
        // the activation services. These could be for both ContextBound
        // and MarshalByRef types.
        internal static IConstructionReturnMessage DoCrossContextActivation(
            IConstructionCallMessage reqMsg)
        {           
            bool bCtxBound = reqMsg.ActivationType.IsContextful;
            ContextTransitionFrame frame = new ContextTransitionFrame();
            if (bCtxBound)
            {
                // If the type is context bound, we need to create 
                // the appropriate context and activate the object inside
                // it.

                // Create a new Context
                Context serverContext = new Context();              

                
                ArrayList list = (ArrayList) reqMsg.ContextProperties;
                Assembly asm = null;
                for (int i=0; i<list.Count; i++)
                {
                    IContextProperty prop = list[i] as IContextProperty;
                    if (null == prop)
                    {
                        throw new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_BadAttribute"));
                    }
                    asm = prop.GetType().Assembly; 
                    // Make a security check to ensure that the context property
                    // is from a trusted assembly!
		    CheckForInfrastructurePermission(asm);

                    // This ensures that we don't try to add duplicate
                    // attributes (eg. type attributes common on both client
                    // and server end)
                    if (serverContext.GetProperty(prop.Name) == null)
                    {
                        serverContext.SetProperty(prop);
                    }
                }
                // No more property changes to the server context from here.
                serverContext.Freeze();

                // (This seems like an overkill but that is how it is spec-ed)
                // Ask each of the properties in the context we formed from
                // if it is happy with the current context.
                for (int i=0; i<list.Count;i++)
                {
                    if (!((IContextProperty)list[i]).IsNewContextOK(
                        serverContext))
                    {
                        throw new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_PropertyUnhappy"));
                    }
                }

                // Change to server context
                Thread.CurrentThread.EnterContext(serverContext, ref frame);
            }

            // call the first sink in the server context chain
            IMethodReturnMessage retMsg =  (IMethodReturnMessage) 
                    Thread.CurrentContext.GetServerContextChain().SyncProcessMessage(reqMsg);

            // The return message may not be of type
            // IConstructionReturnMessage if an exception happens
            // in the sink chains.
            Exception e = null;
            IConstructionReturnMessage replyMsg = retMsg as IConstructionReturnMessage;
            if (null == replyMsg)
            {
                if (retMsg != null)
                {
                    e = retMsg.Exception;
                }
                else
                {
                    e = new RemotingException(
                            Environment.GetResourceString(
                                "Remoting_Activation_Failed"));

                }
                replyMsg = new ConstructorReturnMessage(e,null); 
                // We have created our own message ... transfer the callcontext
                // from the request message.
                ((ConstructorReturnMessage)replyMsg).SetLogicalCallContext(
                        (LogicalCallContext)
                        reqMsg.Properties[Message.CallContextKey]);
            }

            if (bCtxBound)
            {
                Thread.CurrentThread.ReturnToContext(ref frame);
            }

            return replyMsg;
        }
Exemplo n.º 7
0
        public void BeginReadMessage()
        {
            // This is just a temporary and ignored array used on the WriteFile calls.
            byte[] _numReadWritten = new byte[4];

            // TODO: Fix the pinvoke to eliminate these byte arrays
            byte[] intBytes = new byte[4];
            byte[] msgBytes = null;
            int len;

            bool fOk = PipeNative.ReadFile(_handle,
                                intBytes,
                                4,
                                _numReadWritten,
                                0);
            if (fOk)
            {
                len = BitConverter.ToInt32(intBytes, 0);

                msgBytes = new byte[len];

                fOk = PipeNative.ReadFile(_handle,
                               msgBytes,
                               (uint)len,
                               _numReadWritten,
                               0);
            }

            if (!fOk)
            {
                throw new PipeIOException("Error reading from pipe " + _handle + ": error " + PipeNative.GetLastError());
            }

            _stream = new MemoryStream(msgBytes, false);

                if (_stream.CanRead)
                {
                    string s = GetStringFromStream(_stream);
                    if (s.Contains("Exception"))
                    {
                        RemotingException rex = new RemotingException(s);
                        throw rex;

                    }
                }

            _stream.Position = 0;
            _reader = new BinaryReader(_stream, Encoding.UTF8);
        }
 internal static object DoCrossContextActivationCallback(object[] args)
 {
     IConstructionCallMessage msg = (IConstructionCallMessage) args[0];
     IConstructionReturnMessage message2 = null;
     IMethodReturnMessage message3 = (IMethodReturnMessage) Thread.CurrentContext.GetServerContextChain().SyncProcessMessage(msg);
     Exception e = null;
     message2 = message3 as IConstructionReturnMessage;
     if (message2 == null)
     {
         if (message3 != null)
         {
             e = message3.Exception;
         }
         else
         {
             e = new RemotingException(Environment.GetResourceString("Remoting_Activation_Failed"));
         }
         message2 = new ConstructorReturnMessage(e, null);
         ((ConstructorReturnMessage) message2).SetLogicalCallContext((LogicalCallContext) msg.Properties[Message.CallContextKey]);
     }
     return message2;
 }