Exemplo n.º 1
0
 internal RedirectionProxy(MarshalByRefObject proxy, Type serverType)
 {
     _proxy = proxy;
     _realProxy = RemotingServices.GetRealProxy(_proxy);
     _serverType = serverType;
     _objectMode = WellKnownObjectMode.Singleton;
 } // RedirectionProxy
Exemplo n.º 2
0
        // Default implementation of CreateProxy creates an instance of our
        // remoting proxy
        /// <include file='doc\ProxyAttribute.uex' path='docs/doc[@for="ProxyAttribute.CreateProxy"]/*' />

        public virtual RealProxy CreateProxy(ObjRef objRef,
                                             Type serverType,
                                             Object serverObject,
                                             Context serverContext)
        {
            RemotingProxy rp = new RemotingProxy(serverType);

            // If this is a serverID, set the native context field in the TP
            if (null != serverContext)
            {
                RealProxy.SetStubData(rp, serverContext.InternalContextID);
            }

            // Set the flag indicating that the fields of the proxy
            // have been initialized
            rp.Initialized = true;

            // Sanity check
            Type t = serverType;

            if (!t.IsContextful &&
                !t.IsMarshalByRef &&
                (null != serverContext))
            {
                throw new RemotingException(
                          Environment.GetResourceString(
                              "Remoting_Activation_MBR_ProxyAttribute"));
            }

            return(rp);
        }
Exemplo n.º 3
0
        internal object LoadRemoteFieldNew(IntPtr classPtr, IntPtr fieldPtr)
        {
            Mono.RuntimeClassHandle classHandle = new Mono.RuntimeClassHandle(classPtr);
            RuntimeFieldHandle      fieldHandle = new RuntimeFieldHandle(fieldPtr);
            RuntimeTypeHandle       typeHandle  = classHandle.GetTypeHandle();

            FieldInfo field = FieldInfo.GetFieldFromHandle(fieldHandle);

            if (InCurrentContext())
            {
                object o = _rp._server;
                return(field.GetValue(o));
            }

            object[] inArgs = new object[] { Type.GetTypeFromHandle(typeHandle).FullName,
                                             field.Name };
            object[]   outArgsMsg = new object[1];
            MethodInfo minfo      = typeof(object).GetMethod("FieldGetter", BindingFlags.NonPublic | BindingFlags.Instance);

            if (minfo == null)
            {
                throw new MissingMethodException("System.Object", "FieldGetter");
            }
            MonoMethodMessage msg = new MonoMethodMessage(minfo, inArgs, outArgsMsg);

            object[]  outArgs;
            Exception exc;

            RealProxy.PrivateInvoke(_rp, msg, out exc, out outArgs);
            if (exc != null)
            {
                throw exc;
            }
            return(outArgs[0]);
        }
 internal SCUnMarshaler(Type _servertype, byte[] _buffer)
 {
     this.buffer = _buffer;
     this.servertype = _servertype;
     this._rp = null;
     this._fUnMarshaled = false;
 }
 protected ServicedComponentMarshaler(SerializationInfo info, StreamingContext context) : base(info, context)
 {
     byte[] buffer = null;
     Type type = null;
     bool flag = false;
     ComponentServices.InitializeRemotingChannels();
     SerializationInfoEnumerator enumerator = info.GetEnumerator();
     while (enumerator.MoveNext())
     {
         if (enumerator.Name.Equals("servertype"))
         {
             type = (Type) enumerator.Value;
         }
         else
         {
             if (enumerator.Name.Equals("dcomInfo"))
             {
                 buffer = (byte[]) enumerator.Value;
                 continue;
             }
             if (enumerator.Name.Equals("fIsMarshalled"))
             {
                 int num = 0;
                 object obj2 = enumerator.Value;
                 if (obj2.GetType() == typeof(string))
                 {
                     num = ((IConvertible) obj2).ToInt32(null);
                 }
                 else
                 {
                     num = (int) obj2;
                 }
                 if (num == 0)
                 {
                     flag = true;
                 }
             }
         }
     }
     if (!flag)
     {
         this._marshalled = true;
     }
     this._um = new SCUnMarshaler(type, buffer);
     this._rt = type;
     if (base.IsFromThisProcess() && !ServicedComponentInfo.IsTypeEventSource(type))
     {
         this._rp = RemotingServices.GetRealProxy(base.GetRealObject(context));
     }
     else
     {
         if (ServicedComponentInfo.IsTypeEventSource(type))
         {
             this.TypeInfo = new SCMTypeName(type);
         }
         object realObject = base.GetRealObject(context);
         this._rp = RemotingServices.GetRealProxy(realObject);
     }
     this._um.Dispose();
 }
Exemplo n.º 6
0
        private static void HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
        {
            IMethodReturnMessage methodReturnMessage = retMsg as IMethodReturnMessage;

            if (retMsg == null || methodReturnMessage == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Message_BadType"));
            }
            Exception exception = methodReturnMessage.Exception;

            if (exception != null)
            {
                throw exception.PrepForRemoting();
            }
            if (retMsg is StackBasedReturnMessage)
            {
                return;
            }
            if (reqMsg is Message)
            {
                RealProxy.PropagateOutParameters(reqMsg, methodReturnMessage.Args, methodReturnMessage.ReturnValue);
            }
            else
            {
                if (!(reqMsg is ConstructorCallMessage))
                {
                    return;
                }
                RealProxy.PropagateOutParameters(reqMsg, methodReturnMessage.Args, (object)null);
            }
        }
 public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
 {
     object transparentProxy = oldcp.GetTransparentProxy();
     object tp = newcp.GetTransparentProxy();
     RemotingServices.GetServerContextForProxy(transparentProxy);
     RemotingServices.GetServerContextForProxy(tp);
     Marshal.InternalSwitchCCW(transparentProxy, tp);
 }
 internal RealProxy GetRealProxy()
 {
     if ((this._rp == null) && !this._fUnMarshaled)
     {
         this._rp = this.UnmarshalRemoteReference();
     }
     return this._rp;
 }
Exemplo n.º 9
0
        public RemotingInvocation(RealProxy proxy, IMethodCallMessage message)
        {
            this.message = message;
            this.proxy = proxy;

            arguments = message.Args;
            if (arguments == null)
                arguments = new object[0];
        }
Exemplo n.º 10
0
        internal virtual void Wrap()
        {
            ServerIdentity serverIdentity = this._identity as ServerIdentity;

            if (serverIdentity != null && this is RemotingProxy)
            {
                RealProxy.SetStubData(this, serverIdentity.ServerContext.InternalContextID);
            }
        }
Exemplo n.º 11
0
        private IntPtr _stub;           // Unmanaged code that decides whether to short circuit calls or not
     
 		// This method should never be called.  Its sole purpose is to shut up the compiler
		//	because it warns about private fields that are never used.  Most of these fields
		//	are used in unmanaged code.
#if _DEBUG
		private int NeverCallThis()
		{
			BCLDebug.Assert(false,"NeverCallThis");
			_rp = null;
			_pMT = new IntPtr(RemotingServices.TrashMemory);
			_pInterfaceMT = new IntPtr(RemotingServices.TrashMemory);
            _stub = new IntPtr(RemotingServices.TrashMemory);
			RealProxy rp = _rp;
			return _pInterfaceMT.ToInt32();
		}
Exemplo n.º 12
0
		private static void InvokeRealProxy(RealProxy realProxy, WcfInvocation wcfInvocation)
		{
			var message = new MethodCallMessage(wcfInvocation.Method, wcfInvocation.Arguments);
			var returnMessage = (IMethodReturnMessage)realProxy.Invoke(message);
			if (returnMessage.Exception != null)
			{
				throw returnMessage.Exception;
			}
			wcfInvocation.ReturnValue = returnMessage.ReturnValue;
		}
Exemplo n.º 13
0
        internal virtual void Wrap()
        {
            ServerIdentity serverIdentity = this._identity as ServerIdentity;

            if (serverIdentity == null || !(this is RemotingProxy))
            {
                return;
            }
            RealProxy.SetStubData(this, (object)serverIdentity.ServerContext.InternalContextID);
        }
Exemplo n.º 14
0
        private IntPtr _stub;           // Unmanaged code that decides whether to short circuit calls or not

        // This method should never be called.  Its sole purpose is to shut up the compiler
        //	because it warns about private fields that are never used.  Most of these fields
        //	are used in unmanaged code.
#if _DEBUG
        private int NeverCallThis()
        {
            BCLDebug.Assert(false, "NeverCallThis");
            _rp           = null;
            _pMT          = new IntPtr(RemotingServices.TrashMemory);
            _pInterfaceMT = new IntPtr(RemotingServices.TrashMemory);
            _stub         = new IntPtr(RemotingServices.TrashMemory);
            RealProxy rp = _rp;

            return(_pInterfaceMT.ToInt32());
        }
Exemplo n.º 15
0
		private static void InvokeRealProxy(RealProxy realProxy, WcfInvocation wcfInvocation)
		{
			var message = new MethodCallMessage(wcfInvocation.Method, wcfInvocation.Arguments);
			var returnMessage = (IMethodReturnMessage)realProxy.Invoke(message);
			if (returnMessage.Exception != null)
			{
				var exception = ExceptionHelper.PreserveStackTrace(returnMessage.Exception);
				throw exception;
			}
			wcfInvocation.ReturnValue = returnMessage.ReturnValue;
		}
Exemplo n.º 16
0
 private void SetContextForDefaultStub()
 {
     if (this.GetStub() == RealProxy._defaultStub)
     {
         object stubData = RealProxy.GetStubData(this);
         if (stubData is IntPtr && ((IntPtr)stubData).Equals(RealProxy._defaultStubValue))
         {
             RealProxy.SetStubData(this, Thread.CurrentContext.InternalContextID);
         }
     }
 }
Exemplo n.º 17
0
 // Get the stub data within a proxy.
 public static Object GetStubData(RealProxy rp)
 {
     if (rp != null)
     {
         return(rp.stubData);
     }
     else
     {
         return(null);
     }
 }
        [System.Security.SecurityCritical]  // auto-generated_required
        public static void SwitchWrappers(RealProxy oldcp, RealProxy newcp)
        {
            Object oldtp = oldcp.GetTransparentProxy(); 
            Object newtp = newcp.GetTransparentProxy();
 
            IntPtr oldcontextId = RemotingServices.GetServerContextForProxy(oldtp); 
            IntPtr newcontextId = RemotingServices.GetServerContextForProxy(newtp);
 
            // switch the CCW from oldtp to new tp
            Marshal.InternalSwitchCCW(oldtp, newtp);
        }
Exemplo n.º 19
0
 public ObjectCall(
     RealProxy proxy,
     IMessage callMessage,
     Action<IConstructionCallMessage> validationOnInit = null,
     Action<IMethodCallMessage> validationOnAction = null)
 {
     this.proxy = proxy;
     this.callMessage = callMessage;
     this.validationOnInit = validationOnInit;
     this.validationOnAction = validationOnAction;
 }
Exemplo n.º 20
0
 /// <summary>Returns the <see cref="T:System.Type" /> of the object that the current instance of <see cref="T:System.Runtime.Remoting.Proxies.RealProxy" /> represents.</summary>
 /// <returns>The <see cref="T:System.Type" /> of the object that the current instance of <see cref="T:System.Runtime.Remoting.Proxies.RealProxy" /> represents.</returns>
 /// <PermissionSet>
 ///   <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Infrastructure" />
 /// </PermissionSet>
 public Type GetProxiedType()
 {
     if (this._objTP != null)
     {
         return(RealProxy.InternalGetProxyType(this._objTP));
     }
     if (this.class_to_proxy.IsInterface)
     {
         return(typeof(MarshalByRefObject));
     }
     return(this.class_to_proxy);
 }
Exemplo n.º 21
0
        private void SetContextForDefaultStub()
        {
            if (!(this.GetStub() == RealProxy._defaultStub))
            {
                return;
            }
            object stubData = RealProxy.GetStubData(this);

            if (!(stubData is IntPtr) || !((IntPtr)stubData).Equals((object)RealProxy._defaultStubValue))
            {
                return;
            }
            RealProxy.SetStubData(this, (object)Thread.CurrentContext.InternalContextID);
        }
Exemplo n.º 22
0
        internal bool DoContextsMatch()
        {
            bool flag = false;

            if (this.GetStub() == RealProxy._defaultStub)
            {
                object stubData = RealProxy.GetStubData(this);
                if (stubData is IntPtr && ((IntPtr)stubData).Equals((object)Thread.CurrentContext.InternalContextID))
                {
                    flag = true;
                }
            }
            return(flag);
        }
Exemplo n.º 23
0
        private static void Invoke(object NotUsed, ref MessageData msgData)
        {
            Message reqMcmMsg = new Message();

            reqMcmMsg.InitFields(msgData);
            Delegate thisPtr = reqMcmMsg.GetThisPtr() as Delegate;

            if (thisPtr == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Default"));
            }
            RemotingProxy realProxy = (RemotingProxy)RemotingServices.GetRealProxy(thisPtr.Target);

            if (realProxy != null)
            {
                realProxy.InternalInvoke(reqMcmMsg, true, reqMcmMsg.GetCallType());
            }
            else
            {
                int callType = reqMcmMsg.GetCallType();
                switch (callType)
                {
                case 1:
                case 9:
                {
                    reqMcmMsg.Properties[Message.CallContextKey] = CallContext.GetLogicalCallContext().Clone();
                    AsyncResult          retVal = new AsyncResult(reqMcmMsg);
                    AgileAsyncWorkerItem state  = new AgileAsyncWorkerItem(reqMcmMsg, ((callType & 8) != 0) ? null : retVal, thisPtr.Target);
                    ThreadPool.QueueUserWorkItem(new WaitCallback(AgileAsyncWorkerItem.ThreadPoolCallBack), state);
                    if ((callType & 8) != 0)
                    {
                        retVal.SyncProcessMessage(null);
                    }
                    reqMcmMsg.PropagateOutParameters(null, retVal);
                    break;
                }

                case 2:
                    RealProxy.EndInvokeHelper(reqMcmMsg, false);
                    return;

                case 10:
                    break;

                default:
                    return;
                }
            }
        }
Exemplo n.º 24
0
        // Token: 0x06005742 RID: 22338 RVA: 0x00133030 File Offset: 0x00131230
        private static void Invoke(object NotUsed, ref MessageData msgData)
        {
            Message message = new Message();

            message.InitFields(msgData);
            object   thisPtr = message.GetThisPtr();
            Delegate @delegate;

            if ((@delegate = (thisPtr as Delegate)) == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Default"));
            }
            RemotingProxy remotingProxy = (RemotingProxy)RemotingServices.GetRealProxy(@delegate.Target);

            if (remotingProxy != null)
            {
                remotingProxy.InternalInvoke(message, true, message.GetCallType());
                return;
            }
            int callType = message.GetCallType();

            if (callType <= 2)
            {
                if (callType != 1)
                {
                    if (callType != 2)
                    {
                        return;
                    }
                    RealProxy.EndInvokeHelper(message, false);
                    return;
                }
            }
            else if (callType != 9)
            {
                return;
            }
            message.Properties[Message.CallContextKey] = Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext.Clone();
            AsyncResult          asyncResult = new AsyncResult(message);
            AgileAsyncWorkerItem state       = new AgileAsyncWorkerItem(message, ((callType & 8) != 0) ? null : asyncResult, @delegate.Target);

            ThreadPool.QueueUserWorkItem(new WaitCallback(AgileAsyncWorkerItem.ThreadPoolCallBack), state);
            if ((callType & 8) != 0)
            {
                asyncResult.SyncProcessMessage(null);
            }
            message.PropagateOutParameters(null, asyncResult);
        }
        public virtual RealProxy CreateProxy(ObjRef objRef, Type serverType, object serverObject, Context serverContext)
        {
            RemotingProxy remotingProxy = new RemotingProxy(serverType);

            if (serverContext != null)
            {
                RealProxy.SetStubData(remotingProxy, serverContext.InternalContextID);
            }
            if (objRef != null && objRef.GetServerIdentity().IsAllocated)
            {
                remotingProxy.SetSrvInfo(objRef.GetServerIdentity(), objRef.GetDomainID());
            }
            remotingProxy.Initialized = true;
            if (!serverType.IsContextful && !serverType.IsMarshalByRef && serverContext != null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Activation_MBR_ProxyAttribute"));
            }
            return(remotingProxy);
        }
Exemplo n.º 26
0
        internal void StoreRemoteField(IntPtr classPtr, IntPtr fieldPtr, object arg)
        {
            Mono.RuntimeClassHandle classHandle = new Mono.RuntimeClassHandle(classPtr);
            RuntimeFieldHandle      fieldHandle = new RuntimeFieldHandle(fieldPtr);
            RuntimeTypeHandle       typeHandle  = classHandle.GetTypeHandle();
            FieldInfo field = FieldInfo.GetFieldFromHandle(fieldHandle);

            if (InCurrentContext())
            {
                object o = _rp._server;
                field.SetValue(o, arg);
                return;
            }

            string typeName  = Type.GetTypeFromHandle(typeHandle).FullName;
            string fieldName = field.Name;

            object [] inArgs = new object[] { typeName,
                                              fieldName,
                                              arg };
            MethodInfo minfo = typeof(object).GetMethod("FieldSetter", BindingFlags.NonPublic | BindingFlags.Instance);

            if (minfo == null)
            {
                throw new MissingMethodException("System.Object", "FieldSetter");
            }

            MonoMethodMessage msg = new MonoMethodMessage(minfo, inArgs, null);

            object [] outArgs;
            Exception exc;

            RealProxy.PrivateInvoke(_rp, msg, out exc, out outArgs);
            if (exc != null)
            {
                throw exc;
            }
        }
Exemplo n.º 27
0
 public static extern void SetStubData(RealProxy rp, Object stubData);
Exemplo n.º 28
0
 public static void SetStubData(RealProxy rp, object stubData)
 {
     rp._stubData = stubData;
 }
 //
 // Summary:
 //     Sets the stub data for the specified proxy.
 //
 // Parameters:
 //   rp:
 //     The proxy for which to set stub data.
 //
 //   stubData:
 //     The new stub data.
 //
 // Exceptions:
 //   System.Security.SecurityException:
 //     The immediate caller does not have UnmanagedCode permission.
 public static void SetStubData(RealProxy rp, object stubData);
Exemplo n.º 30
0
        [System.Security.SecurityCritical]  // auto-generated 
        internal static Object CreateTransparentProxy(
            RealProxy rp,
            Type typeToProxy,
            IntPtr stub, 
            Object stubData)
        { 
            RuntimeType rTypeToProxy = typeToProxy as RuntimeType; 
            if (rTypeToProxy == null)
                throw new ArgumentException( 
                            String.Format(
                                CultureInfo.CurrentCulture, Environment.GetResourceString(
                                    "Argument_WrongType"),
                                "typeToProxy" 
                                )
                            ); 
 
            return CreateTransparentProxy(
                        rp, 
                        rTypeToProxy,
                        stub,
                        stubData);
        } 
Exemplo n.º 31
0
 [System.Security.SecurityCritical]  // auto-generated
 internal static bool ProxyCheckCast(RealProxy rp, RuntimeType castType)
 {
     return CheckCast(rp, castType); 
 } // ProxyCheckCast
Exemplo n.º 32
0
 public static extern Object GetStubData(RealProxy rp); 
Exemplo n.º 33
0
		public StackBuilderSink (MarshalByRefObject obj, bool forceInternalExecute)
		{
			_target = obj;
			if (!forceInternalExecute && RemotingServices.IsTransparentProxy (obj))
				_rp = RemotingServices.GetRealProxy (obj);
		}
Exemplo n.º 34
0
        private void PrivateInvoke(ref MessageData msgData, int type)
        {
            IMessage      message1      = (IMessage)null;
            CallType      callType      = (CallType)type;
            IMessage      message2      = (IMessage)null;
            int           msgFlags      = -1;
            RemotingProxy remotingProxy = (RemotingProxy)null;

            if (CallType.MethodCall == callType)
            {
                Message     message3 = new Message();
                MessageData msgData1 = msgData;
                message3.InitFields(msgData1);
                message1 = (IMessage)message3;
                msgFlags = message3.GetCallType();
            }
            else if (CallType.ConstructorCall == callType)
            {
                msgFlags      = 0;
                remotingProxy = this as RemotingProxy;
                bool flag = false;
                ConstructorCallMessage constructorCallMessage1;
                if (!this.IsRemotingProxy())
                {
                    constructorCallMessage1 = new ConstructorCallMessage((object[])null, (object[])null, (object[])null, (RuntimeType)this.GetProxiedType());
                }
                else
                {
                    constructorCallMessage1 = remotingProxy.ConstructorMessage;
                    Identity identityObject = remotingProxy.IdentityObject;
                    if (identityObject != null)
                    {
                        flag = identityObject.IsWellKnown();
                    }
                }
                if (constructorCallMessage1 == null | flag)
                {
                    ConstructorCallMessage constructorCallMessage2 = new ConstructorCallMessage((object[])null, (object[])null, (object[])null, (RuntimeType)this.GetProxiedType());
                    constructorCallMessage2.SetFrame(msgData);
                    message1 = (IMessage)constructorCallMessage2;
                    if (flag)
                    {
                        remotingProxy.ConstructorMessage = (ConstructorCallMessage)null;
                        if (constructorCallMessage2.ArgCount != 0)
                        {
                            throw new RemotingException(Environment.GetResourceString("Remoting_Activation_WellKnownCTOR"));
                        }
                    }
                    message2 = (IMessage) new ConstructorReturnMessage((MarshalByRefObject)this.GetTransparentProxy(), (object[])null, 0, (LogicalCallContext)null, (IConstructionCallMessage)constructorCallMessage2);
                }
                else
                {
                    constructorCallMessage1.SetFrame(msgData);
                    message1 = (IMessage)constructorCallMessage1;
                }
            }
            ChannelServices.IncrementRemoteCalls();
            if (!this.IsRemotingProxy() && (msgFlags & 2) == 2)
            {
                message2 = RealProxy.EndInvokeHelper(message1 as Message, true);
            }
            if (message2 == null)
            {
                Thread             currentThread      = Thread.CurrentThread;
                LogicalCallContext logicalCallContext = currentThread.GetMutableExecutionContext().LogicalCallContext;
                this.SetCallContextInMessage(message1, msgFlags, logicalCallContext);
                logicalCallContext.PropagateOutgoingHeadersToMessage(message1);
                message2 = this.Invoke(message1);
                this.ReturnCallContextToThread(currentThread, message2, msgFlags, logicalCallContext);
                Thread.CurrentThread.GetMutableExecutionContext().LogicalCallContext.PropagateIncomingHeadersToCallContext(message2);
            }
            if (!this.IsRemotingProxy() && (msgFlags & 1) == 1)
            {
                Message     m           = message1 as Message;
                AsyncResult asyncResult = new AsyncResult(m);
                IMessage    msg         = message2;
                asyncResult.SyncProcessMessage(msg);
                // ISSUE: variable of the null type
                __Null local1       = null;
                int    outArgsCount = 0;
                // ISSUE: variable of the null type
                __Null  local2   = null;
                Message message3 = m;
                message2 = (IMessage) new ReturnMessage((object)asyncResult, (object[])local1, outArgsCount, (LogicalCallContext)local2, (IMethodCallMessage)message3);
            }
            RealProxy.HandleReturnMessage(message1, message2);
            if (CallType.ConstructorCall != callType)
            {
                return;
            }
            IConstructionReturnMessage constructionReturnMessage = message2 as IConstructionReturnMessage;

            if (constructionReturnMessage == null)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_BadReturnTypeForActivation"));
            }
            ConstructorReturnMessage constructorReturnMessage = constructionReturnMessage as ConstructorReturnMessage;
            MarshalByRefObject       marshalByRefObject;

            if (constructorReturnMessage != null)
            {
                marshalByRefObject = (MarshalByRefObject)constructorReturnMessage.GetObject();
                if (marshalByRefObject == null)
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_Activation_NullReturnValue"));
                }
            }
            else
            {
                marshalByRefObject = (MarshalByRefObject)RemotingServices.InternalUnmarshal((ObjRef)constructionReturnMessage.ReturnValue, this.GetTransparentProxy(), true);
                if (marshalByRefObject == null)
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_Activation_NullFromInternalUnmarshal"));
                }
            }
            if (marshalByRefObject != (MarshalByRefObject)this.GetTransparentProxy())
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Activation_InconsistentState"));
            }
            if (!this.IsRemotingProxy())
            {
                return;
            }
            remotingProxy.ConstructorMessage = (ConstructorCallMessage)null;
        }
Exemplo n.º 35
0
        internal static void PropagateOutParameters(IMessage msg, object[] outArgs, object returnValue)
        {
            Message message = msg as Message;

            if (message == null)
            {
                ConstructorCallMessage constructorCallMessage = msg as ConstructorCallMessage;
                if (constructorCallMessage != null)
                {
                    message = constructorCallMessage.GetMessage();
                }
            }
            if (message == null)
            {
                throw new ArgumentException(Environment.GetResourceString("Remoting_Proxy_ExpectedOriginalMessage"));
            }
            RemotingMethodCachedData reflectionCachedData = InternalRemotingServices.GetReflectionCachedData(message.GetMethodBase());

            if (outArgs != null && outArgs.Length != 0)
            {
                object[]        args       = message.Args;
                ParameterInfo[] parameters = reflectionCachedData.Parameters;
                foreach (int marshalRequestArg in reflectionCachedData.MarshalRequestArgMap)
                {
                    ParameterInfo parameterInfo = parameters[marshalRequestArg];
                    if (parameterInfo.IsIn && parameterInfo.ParameterType.IsByRef && !parameterInfo.IsOut)
                    {
                        outArgs[marshalRequestArg] = args[marshalRequestArg];
                    }
                }
                if (reflectionCachedData.NonRefOutArgMap.Length != 0)
                {
                    foreach (int nonRefOutArg in reflectionCachedData.NonRefOutArgMap)
                    {
                        Array array = args[nonRefOutArg] as Array;
                        if (array != null)
                        {
                            Array sourceArray      = (Array)outArgs[nonRefOutArg];
                            Array destinationArray = array;
                            int   length           = destinationArray.Length;
                            Array.Copy(sourceArray, destinationArray, length);
                        }
                    }
                }
                int[] outRefArgMap = reflectionCachedData.OutRefArgMap;
                if (outRefArgMap.Length != 0)
                {
                    foreach (int index in outRefArgMap)
                    {
                        RealProxy.ValidateReturnArg(outArgs[index], parameters[index].ParameterType);
                    }
                }
            }
            if ((message.GetCallType() & 15) != 1)
            {
                Type returnType = reflectionCachedData.ReturnType;
                if (returnType != (Type)null)
                {
                    RealProxy.ValidateReturnArg(returnValue, returnType);
                }
            }
            message.PropagateOutParameters(outArgs, returnValue);
        }
Exemplo n.º 36
0
 public static extern object GetStubData(RealProxy rp);
Exemplo n.º 37
0
        // Invoke for case where call is in the same context as the server object
        // (This special static method is used for AsyncDelegate-s ... this is called
        // directly from the EE)
        private static void Invoke(Object NotUsed, ref MessageData msgData)
        {
            Message m = new Message();

            m.InitFields(msgData);

            Object   thisPtr = m.GetThisPtr();
            Delegate d;

            if ((d = thisPtr as Delegate) != null)
            {
                RemotingProxy rp = (RemotingProxy)
                                   RemotingServices.GetRealProxy(d.Target);

                if (rp != null)
                {
                    rp.InternalInvoke(m, true, m.GetCallType());
                }
                else
                {
                    int         callType = m.GetCallType();
                    AsyncResult ar;
                    switch (callType)
                    {
                    case Message.BeginAsync:
                    case Message.BeginAsync | Message.OneWay:
                        // pick up call context from the thread
                        m.Properties[Message.CallContextKey] =
                            CallContext.GetLogicalCallContext().Clone();
                        ar = new AsyncResult(m);
                        AgileAsyncWorkerItem workItem =
                            new AgileAsyncWorkerItem(
                                m,
                                ((callType & Message.OneWay) != 0) ?
                                null : ar, d.Target);

                        ThreadPool.QueueUserWorkItem(
                            new WaitCallback(
                                AgileAsyncWorkerItem.ThreadPoolCallBack),
                            workItem);

                        if ((callType & Message.OneWay) != 0)
                        {
                            ar.SyncProcessMessage(null);
                        }
                        m.PropagateOutParameters(null, ar);
                        break;

                    case (Message.EndAsync | Message.OneWay):
                        return;

                    case Message.EndAsync:
                        // This will also merge back the call context
                        // onto the thread that called EndAsync
                        RealProxy.EndInvokeHelper(m, false);
                        break;

                    default:
                        BCLDebug.Assert(
                            false,
                            "Should never be here. Sync delegate code for agile object ended up in remoting");
                        break;
                    }
                }
            }
            else
            {
                // Static invoke called with incorrect this pointer ...
                throw new RemotingException(
                          Environment.GetResourceString(
                              "Remoting_Default"));
            }
        }
 internal RemotingIntermediary(RealProxy pxy) : base(pxy.GetProxiedType())
 {
     this._pxy = pxy;
     this._blind = new BlindMBRO((MarshalByRefObject) this.GetTransparentProxy());
 }
 internal MbrObject(RealProxy proxy, System.Type targetType)
 {
     this.proxy = proxy;
     this.targetType = targetType;
 }
Exemplo n.º 40
0
        /* this is called from unmanaged code */
        internal static object PrivateInvoke(RealProxy rp, IMessage msg, out Exception exc,
                                             out object [] out_args)
        {
            //MonoMethodMessage mMsg = (MonoMethodMessage) msg;
            //mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext (true);
            //CallType call_type = mMsg.CallType;
            //bool is_remproxy = (rp as RemotingProxy) != null;

            //IMethodReturnMessage res_msg = null;

            //if (call_type == CallType.BeginInvoke)
            //    // todo: set CallMessage in runtime instead
            //    mMsg.AsyncResult.CallMessage = mMsg;

            //if (call_type == CallType.EndInvoke)
            //    res_msg = (IMethodReturnMessage)mMsg.AsyncResult.EndInvoke ();

            //// Check for constructor msg
            //if (mMsg.MethodBase.IsConstructor)
            //{
            //    if (is_remproxy)
            //        res_msg = (IMethodReturnMessage) (rp as RemotingProxy).ActivateRemoteObject ((IMethodMessage) msg);
            //    else
            //        msg = new ConstructionCall (rp.GetProxiedType ());
            //}

            //if (null == res_msg)
            //{
            //    res_msg = (IMethodReturnMessage)rp.Invoke (msg);

            //    // Note, from begining this code used AsyncResult.IsCompleted for
            //    // checking if it was a remoting or custom proxy, but in some
            //    // cases the remoting proxy finish before the call returns
            //    // causing this method to be called, therefore causing all kind of bugs.
            //    if ((!is_remproxy) && call_type == CallType.BeginInvoke)
            //    {
            //        IMessage asyncMsg = null;

            //        // allow calltype EndInvoke to finish
            //        asyncMsg = mMsg.AsyncResult.SyncProcessMessage (res_msg as IMessage);
            //        res_msg = new ReturnMessage (asyncMsg, null, 0, null, res_msg as IMethodCallMessage);
            //    }
            //}

            //if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
            //    CallContext.UpdateCurrentCallContext (res_msg.LogicalCallContext);

            //exc = res_msg.Exception;

            //// todo: remove throw exception from the runtime invoke
            //if (null != exc) {
            //    out_args = null;
            //    throw exc.FixRemotingException();
            //}
            //else if (res_msg is IConstructionReturnMessage || mMsg.CallType == CallType.BeginInvoke) {
            //    out_args = res_msg.OutArgs;
            //}
            //else if (mMsg.CallType == CallType.Sync) {
            //    out_args = ProcessResponse (res_msg, mMsg);
            //}
            //else if (mMsg.CallType == CallType.EndInvoke) {
            //    out_args = ProcessResponse (res_msg, mMsg.AsyncResult.CallMessage);
            //}
            //else {
            //    out_args = res_msg.OutArgs;
            //}

            //return res_msg.ReturnValue;
            throw new NotImplementedException();
        }
		public static void SwitchWrappers (RealProxy oldcp, RealProxy newcp)
		{
			throw new NotSupportedException ();
		}
Exemplo n.º 42
0
        } // Invoke

        // This is called for all remoted calls on a TP except Ctors
        // The method called may be Sync, Async or OneWay(special case of Async)
        // In the Async case we come here for both BeginInvoke & EndInvoke
        internal virtual IMessage InternalInvoke(
            IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType)
        {
            Message reqMsg = reqMcmMsg as Message;

            if ((reqMsg == null) && (callType != Message.Sync))
            {
                // Only the synchronous call type is supported for messages that
                //   aren't of type Message.
                throw new RemotingException(
                          Environment.GetResourceString("Remoting_Proxy_InvalidCallType"));
            }

            IMessage retMsg        = null;
            Thread   currentThread = Thread.CurrentThread;

            // pick up call context from the thread
            LogicalCallContext cctx = currentThread.GetLogicalCallContext();

            Identity       idObj    = IdentityObject;
            ServerIdentity serverID = idObj as ServerIdentity;

            if ((null != serverID) && idObj.IsFullyDisconnected())
            {
                throw new ArgumentException(
                          String.Format(Environment.GetResourceString("Remoting_ServerObjectNotFound"), reqMcmMsg.Uri));
            }

            // Short-circuit calls to Object::GetType and Object::GetHashCode
            MethodBase mb = reqMcmMsg.MethodBase;

            if (_getTypeMethod == mb)
            {
                // Time to load the true type of the remote object....
                Type t = GetProxiedType();
                return(new ReturnMessage(t, null, 0, null /*cctx*/, reqMcmMsg));
            }

            if (_getHashCodeMethod == mb)
            {
                int hashCode = idObj.GetHashCode();
                return(new ReturnMessage(hashCode, null, 0, null /*cctx*/, reqMcmMsg));
            }

            // check for channel sink
            if (idObj.ChannelSink == null)
            {
                throw new RemotingException(
                          Environment.GetResourceString("Remoting_Proxy_NoChannelSink"));
            }

            // Set the identity in the message object
            IInternalMessage iim = (IInternalMessage)reqMcmMsg;

            iim.IdentityObject = idObj;

            if (null != serverID)
            {
                Message.DebugOut("Setting serveridentity on message \n");
                iim.ServerIdentityObject = serverID;
            }
            else
            {
                // We need to set the URI only for identities that
                // are not the server identities. The uri is used to
                // dispatch methods for objects outside the appdomain.
                // Inside the appdomain (xcontext case) we dispatch
                // by getting the server object from the server identity.
                iim.SetURI(idObj.URI);
            }

            Message.DebugOut("InternalInvoke. Dispatching based on class type\n");
            AsyncResult ar = null;

            switch (callType)
            {
            case Message.Sync:
                Message.DebugOut("RemotingProxy.Invoke Call: SyncProcessMsg\n");
                BCLDebug.Assert(!useDispatchMessage, "!useDispatchMessage");
                bool         bSkipContextChain = false;
                Context      currentContext    = currentThread.GetCurrentContextInternal();
                IMessageSink nextSink          = idObj.EnvoyChain;

                // if we are in the default context, there can be no
                // client context chain, so we can skip the intermediate
                // calls if there are no envoy sinks

                if (currentContext.IsDefaultContext)
                {
                    if (nextSink is EnvoyTerminatorSink)
                    {
                        bSkipContextChain = true;

                        // jump directly to the channel sink
                        nextSink = idObj.ChannelSink;
                    }
                }

                retMsg = CallProcessMessage(nextSink,
                                            reqMcmMsg,
                                            idObj.ProxySideDynamicSinks,
                                            currentThread,
                                            currentContext,
                                            bSkipContextChain);

                break;

            case Message.BeginAsync:
            case Message.BeginAsync | Message.OneWay:
                // For async calls we clone the call context from the thread
                // This is a limited clone (we dont deep copy the user data)
                cctx = (LogicalCallContext)cctx.Clone();
                iim.SetCallContext(cctx);

                ar = new AsyncResult(reqMsg);

                InternalInvokeAsync(ar, reqMsg, useDispatchMessage, callType);

                Message.DebugOut("Propagate out params for BeginAsync\n");
                retMsg = new ReturnMessage(ar, null, 0, null /*cctx*/, reqMsg);
                break;

            case Message.OneWay:
                // For async calls we clone the call context from the thread
                // This is a limited clone (we dont deep copy the user data)
                cctx = (LogicalCallContext)cctx.Clone();
                iim.SetCallContext(cctx);
                InternalInvokeAsync(null, reqMsg, useDispatchMessage, callType);
                retMsg = new ReturnMessage(null, null, 0, null /*cctx*/, reqMcmMsg);
                break;

            case (Message.EndAsync | Message.OneWay):
                retMsg = new ReturnMessage(null, null, 0, null /*cctx*/, reqMcmMsg);
                break;

            case Message.EndAsync:
                // For endAsync, we merge back the returned callContext
                // into the thread's callContext
                retMsg = RealProxy.EndInvokeHelper(reqMsg, true);
                break;
            }

            return(retMsg);
        }
Exemplo n.º 43
0
 public static extern void SetStubData(RealProxy rp, Object stubData);
Exemplo n.º 44
0
		public static void SetStubData (RealProxy rp, object stubData)
		{
			rp._stubData = stubData;
		}
Exemplo n.º 45
0
        [System.Security.SecurityCritical]  // auto-generated 
        private static bool CheckCast(RealProxy rp, RuntimeType castType)
        { 
            // NOTE: This is the point where JIT_CheckCastClass ultimately 
            // lands up in the managed world if the object being cast is
            // a transparent proxy. 
            // If we are here, it means that walking the current EEClass
            // up the chain inside the EE was unable to verify the cast.

            Message.DebugOut("Entered CheckCast for type " + castType); 
            bool fCastOK = false;
 
            BCLDebug.Assert(rp != null, "Shouldn't be called with null real proxy."); 

            // Always return true if cast is to System.Object 
            if (castType == typeof(Object))
                return true;

            // We do not allow casting to non-interface types that do not extend 
            // from System.MarshalByRefObject
            if (!castType.IsInterface && !castType.IsMarshalByRef) 
                return false; 

            // Note: this is a bit of a hack to allow deserialization of WellKnown 
            // object refs (in the well known cases, we always return TRUE for
            // interface casts but doing so messes us up in the case when
            // the object manager is trying to resolve object references since
            // it ends up thinking that the proxy we returned needs to be resolved 
            // further).
            if (castType != typeof(IObjectReference)) 
            { 
                IRemotingTypeInfo typeInfo = rp as IRemotingTypeInfo;
                if(null != typeInfo) 
                {
                    fCastOK = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
                }
                else 
                {
                    // The proxy does not implement IRemotingTypeInfo, so we should 
                    //   try to do casting based on the ObjRef type info. 
                    Identity id = rp.IdentityObject;
                    if (id != null) 
                    {
                        ObjRef objRef = id.ObjectRef;
                        if (objRef != null)
                        { 
                            typeInfo = objRef.TypeInfo;
                            if (typeInfo != null) 
                            { 
                                fCastOK = typeInfo.CanCastTo(castType, rp.GetTransparentProxy());
                            } 
                        }
                    }
                }
            } 

            Message.DebugOut("CheckCast returning " + fCastOK); 
            return fCastOK; 
        }
Exemplo n.º 46
0
        internal virtual IMessage InternalInvoke(IMethodCallMessage reqMcmMsg, bool useDispatchMessage, int callType)
        {
            Message message1 = reqMcmMsg as Message;

            if (message1 == null && callType != 0)
            {
                throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_InvalidCallType"));
            }
            IMessage           message2           = (IMessage)null;
            Thread             currentThread      = Thread.CurrentThread;
            LogicalCallContext logicalCallContext = currentThread.GetMutableExecutionContext().LogicalCallContext;
            Identity           identityObject     = this.IdentityObject;
            ServerIdentity     serverIdentity     = identityObject as ServerIdentity;

            if (serverIdentity != null && identityObject.IsFullyDisconnected())
            {
                throw new ArgumentException(Environment.GetResourceString("Remoting_ServerObjectNotFound", (object)reqMcmMsg.Uri));
            }
            MethodBase methodBase = reqMcmMsg.MethodBase;

            if ((MethodBase)RemotingProxy._getTypeMethod == methodBase)
            {
                return((IMessage) new ReturnMessage((object)this.GetProxiedType(), (object[])null, 0, logicalCallContext, reqMcmMsg));
            }
            if ((MethodBase)RemotingProxy._getHashCodeMethod == methodBase)
            {
                return((IMessage) new ReturnMessage((object)identityObject.GetHashCode(), (object[])null, 0, logicalCallContext, reqMcmMsg));
            }
            if (identityObject.ChannelSink == null)
            {
                IMessageSink chnlSink  = (IMessageSink)null;
                IMessageSink envoySink = (IMessageSink)null;
                if (!identityObject.ObjectRef.IsObjRefLite())
                {
                    RemotingServices.CreateEnvoyAndChannelSinks((MarshalByRefObject)null, identityObject.ObjectRef, out chnlSink, out envoySink);
                }
                else
                {
                    RemotingServices.CreateEnvoyAndChannelSinks(identityObject.ObjURI, (object)null, out chnlSink, out envoySink);
                }
                RemotingServices.SetEnvoyAndChannelSinks(identityObject, chnlSink, envoySink);
                if (identityObject.ChannelSink == null)
                {
                    throw new RemotingException(Environment.GetResourceString("Remoting_Proxy_NoChannelSink"));
                }
            }
            IInternalMessage internalMessage = (IInternalMessage)reqMcmMsg;

            internalMessage.IdentityObject = identityObject;
            if (serverIdentity != null)
            {
                internalMessage.ServerIdentityObject = serverIdentity;
            }
            else
            {
                internalMessage.SetURI(identityObject.URI);
            }
            switch (callType)
            {
            case 0:
                bool         bSkippingContextChain  = false;
                Context      currentContextInternal = currentThread.GetCurrentContextInternal();
                IMessageSink ms = identityObject.EnvoyChain;
                if (currentContextInternal.IsDefaultContext && ms is EnvoyTerminatorSink)
                {
                    bSkippingContextChain = true;
                    ms = identityObject.ChannelSink;
                }
                message2 = RemotingProxy.CallProcessMessage(ms, (IMessage)reqMcmMsg, identityObject.ProxySideDynamicSinks, currentThread, currentContextInternal, bSkippingContextChain);
                break;

            case 1:
            case 9:
                LogicalCallContext callContext1 = (LogicalCallContext)logicalCallContext.Clone();
                internalMessage.SetCallContext(callContext1);
                AsyncResult asyncResult = new AsyncResult(message1);
                this.InternalInvokeAsync((IMessageSink)asyncResult, message1, useDispatchMessage, callType);
                message2 = (IMessage) new ReturnMessage((object)asyncResult, (object[])null, 0, (LogicalCallContext)null, (IMethodCallMessage)message1);
                break;

            case 2:
                message2 = RealProxy.EndInvokeHelper(message1, true);
                break;

            case 8:
                LogicalCallContext callContext2 = (LogicalCallContext)logicalCallContext.Clone();
                internalMessage.SetCallContext(callContext2);
                this.InternalInvokeAsync((IMessageSink)null, message1, useDispatchMessage, callType);
                message2 = (IMessage) new ReturnMessage((object)null, (object[])null, 0, (LogicalCallContext)null, reqMcmMsg);
                break;

            case 10:
                message2 = (IMessage) new ReturnMessage((object)null, (object[])null, 0, (LogicalCallContext)null, reqMcmMsg);
                break;
            }
            return(message2);
        }
Exemplo n.º 47
0
 internal static extern Object CreateTransparentProxy( 
                                     RealProxy rp, 
                                     RuntimeType typeToProxy,
                                     IntPtr stub, 
                                     Object stubData);
Exemplo n.º 48
0
		internal static bool ProxyCheckCast (RealProxy rp, RuntimeType castType)
		{
			// TODO: What should it do?
			return true;
		}
 //
 // Summary:
 //     Retrieves stub data that is stored for the specified proxy.
 //
 // Parameters:
 //   rp:
 //     The proxy for which stub data is requested.
 //
 // Returns:
 //     Stub data for the specified proxy.
 //
 // Exceptions:
 //   System.Security.SecurityException:
 //     The immediate caller does not have UnmanagedCode permission.
 public static object GetStubData(RealProxy rp);
 public IntermediaryObjRef(MarshalByRefObject mbro, Type reqtype, RealProxy pxy) : base(mbro, reqtype)
 {
     this._custom = pxy.CreateObjRef(reqtype);
 }
Exemplo n.º 51
0
 public static object GetStubData(RealProxy rp)
 {
     return(rp._stubData);
 }
Exemplo n.º 52
0
	// Get the stub data within a proxy.
	public static Object GetStubData(RealProxy rp)
			{
				if(rp != null)
				{
					return rp.stubData;
				}
				else
				{
					return null;
				}
			}
Exemplo n.º 53
0
        /* this is called from unmanaged code */
        internal static object PrivateInvoke(RealProxy rp, IMessage msg, out Exception exc,
                                             out object [] out_args)
        {
            MonoMethodMessage mMsg = (MonoMethodMessage)msg;

            mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext(true);
            CallType call_type   = mMsg.CallType;
            bool     is_remproxy = (rp is RemotingProxy);

            out_args = null;
            IMethodReturnMessage res_msg = null;

            if (call_type == CallType.BeginInvoke)
            {
                // todo: set CallMessage in runtime instead
                mMsg.AsyncResult.CallMessage = mMsg;
            }

            if (call_type == CallType.EndInvoke)
            {
                res_msg = (IMethodReturnMessage)mMsg.AsyncResult.EndInvoke();
            }

            // Check for constructor msg
            if (mMsg.MethodBase.IsConstructor)
            {
                if (is_remproxy)
                {
                    res_msg = (IMethodReturnMessage)(rp as RemotingProxy).ActivateRemoteObject((IMethodMessage)msg);
                }
                else
                {
                    msg = new ConstructionCall(rp.GetProxiedType());
                }
            }

            if (null == res_msg)
            {
                bool failed = false;

                try {
                    res_msg = (IMethodReturnMessage)rp.Invoke(msg);
                } catch (Exception ex) {
                    failed = true;
                    if (call_type == CallType.BeginInvoke)
                    {
                        // If async dispatch crashes, don't propagate the exception.
                        // The exception will be raised when calling EndInvoke.
                        mMsg.AsyncResult.SyncProcessMessage(new ReturnMessage(ex, msg as IMethodCallMessage));
                        res_msg = new ReturnMessage(null, null, 0, null, msg as IMethodCallMessage);
                    }
                    else
                    {
                        throw;
                    }
                }

                // Note, from begining this code used AsyncResult.IsCompleted for
                // checking if it was a remoting or custom proxy, but in some
                // cases the remoting proxy finish before the call returns
                // causing this method to be called, therefore causing all kind of bugs.
                if ((!is_remproxy) && call_type == CallType.BeginInvoke && !failed)
                {
                    IMessage asyncMsg = null;

                    // allow calltype EndInvoke to finish
                    asyncMsg = mMsg.AsyncResult.SyncProcessMessage(res_msg as IMessage);
                    out_args = res_msg.OutArgs;
                    res_msg  = new ReturnMessage(asyncMsg, null, 0, null, res_msg as IMethodCallMessage);
                }
            }

            if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
            {
                CallContext.UpdateCurrentCallContext(res_msg.LogicalCallContext);
            }

            exc = res_msg.Exception;

            // todo: remove throw exception from the runtime invoke
            if (null != exc)
            {
                out_args = null;
                throw exc.FixRemotingException();
            }
            else if (res_msg is IConstructionReturnMessage)
            {
                if (out_args == null)
                {
                    out_args = res_msg.OutArgs;
                }
            }
            else if (mMsg.CallType == CallType.BeginInvoke)
            {
                // We don't have OutArgs in this case.
            }
            else if (mMsg.CallType == CallType.Sync)
            {
                out_args = ProcessResponse(res_msg, mMsg);
            }
            else if (mMsg.CallType == CallType.EndInvoke)
            {
                out_args = ProcessResponse(res_msg, mMsg.AsyncResult.CallMessage);
            }
            else
            {
                if (out_args == null)
                {
                    out_args = res_msg.OutArgs;
                }
            }

            return(res_msg.ReturnValue);
        }
Exemplo n.º 54
0
	// Set the stub data for a particular proxy.
	public static void SetStubData(RealProxy rp, Object stubData)
			{
				if(rp != null)
				{
					rp.stubData = stubData;
				}
			}
Exemplo n.º 55
0
 public static object GetStubData(RealProxy rp)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 56
0
 internal static object PrivateInvoke(RealProxy rp, IMessage msg, out Exception exc,
                                      out object [] out_args)
 {
     throw new PlatformNotSupportedException();
 }
Exemplo n.º 57
0
		public static object GetStubData (RealProxy rp)
		{
			return rp._stubData;
		}
Exemplo n.º 58
0
 public RemotingInvocation(RealProxy realProxy, IMethodCallMessage message)
 {
     _message = message;
     _realProxy = realProxy;
     this._args = (object[])this._message.Properties["__Args"];
 }
Exemplo n.º 59
0
		/* this is called from unmanaged code */
		internal static object PrivateInvoke (RealProxy rp, IMessage msg, out Exception exc,
						      out object [] out_args)
		{
			MonoMethodMessage mMsg = (MonoMethodMessage) msg;
			mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext (true);
			CallType call_type = mMsg.CallType;
#if MOONLIGHT
			bool is_remproxy = false;
#else
			bool is_remproxy = (rp is RemotingProxy);
#endif

			out_args = null;
			IMethodReturnMessage res_msg = null;
			
			if (call_type == CallType.BeginInvoke) 
				// todo: set CallMessage in runtime instead
				mMsg.AsyncResult.CallMessage = mMsg;

			if (call_type == CallType.EndInvoke)
				res_msg = (IMethodReturnMessage)mMsg.AsyncResult.EndInvoke ();

			// Check for constructor msg
			if (mMsg.MethodBase.IsConstructor) 
			{
#if !MOONLIGHT
				if (is_remproxy) 
					res_msg = (IMethodReturnMessage) (rp as RemotingProxy).ActivateRemoteObject ((IMethodMessage) msg);
				else 
#endif
					msg = new ConstructionCall (rp.GetProxiedType ());
			}
				
			if (null == res_msg) 
			{
				bool failed = false;
				
				try {
					res_msg = (IMethodReturnMessage)rp.Invoke (msg);
				} catch (Exception ex) {
					failed = true;
					if (call_type == CallType.BeginInvoke) {
						// If async dispatch crashes, don't propagate the exception.
						// The exception will be raised when calling EndInvoke.
						mMsg.AsyncResult.SyncProcessMessage (new ReturnMessage (ex, msg as IMethodCallMessage));
						res_msg = new ReturnMessage (null, null, 0, null, msg as IMethodCallMessage);
					} else
						throw;
				}
				
				// Note, from begining this code used AsyncResult.IsCompleted for
				// checking if it was a remoting or custom proxy, but in some
				// cases the remoting proxy finish before the call returns
				// causing this method to be called, therefore causing all kind of bugs.
				if ((!is_remproxy) && call_type == CallType.BeginInvoke && !failed)
				{
					IMessage asyncMsg = null;

					// allow calltype EndInvoke to finish
					asyncMsg = mMsg.AsyncResult.SyncProcessMessage (res_msg as IMessage);
					out_args = res_msg.OutArgs;
					res_msg = new ReturnMessage (asyncMsg, null, 0, null, res_msg as IMethodCallMessage);
				}
			}
			
			if (res_msg.LogicalCallContext != null && res_msg.LogicalCallContext.HasInfo)
				CallContext.UpdateCurrentCallContext (res_msg.LogicalCallContext);

			exc = res_msg.Exception;

			// todo: remove throw exception from the runtime invoke
			if (null != exc) {
				out_args = null;
				throw exc.FixRemotingException();
			}
			else if (res_msg is IConstructionReturnMessage) {
				if (out_args == null)
					out_args = res_msg.OutArgs;
			}
			else if (mMsg.CallType == CallType.BeginInvoke) {
				// We don't have OutArgs in this case.
			}
			else if (mMsg.CallType == CallType.Sync) {
				out_args = ProcessResponse (res_msg, mMsg);
			}
			else if (mMsg.CallType == CallType.EndInvoke) {
				out_args = ProcessResponse (res_msg, mMsg.AsyncResult.CallMessage);
			}
			else {
				if (out_args == null)
					out_args = res_msg.OutArgs;
			}

			return res_msg.ReturnValue;
		}
 public TransparentProxyFactory(Type objectType)
 {
     this.objectType = objectType;
     this.realProxy = new RemotingProxy();
 }