* ActivationServices.cs: In Activate, assign the proxy to the ctor
authorLluis Sanchez <lluis@novell.com>
Wed, 22 Sep 2004 19:31:25 +0000 (19:31 -0000)
committerLluis Sanchez <lluis@novell.com>
Wed, 22 Sep 2004 19:31:25 +0000 (19:31 -0000)
  message. In CreateInstanceFromMessage if the object being created
  is a CBO, use the provided proxy as "this" when calling the ctor.

svn path=/trunk/mcs/; revision=34252

mcs/class/corlib/System.Runtime.Remoting.Activation/ActivationServices.cs
mcs/class/corlib/System.Runtime.Remoting.Activation/ChangeLog

index 0a0022f6017008aa1cd53fcd4f8a9788a3334ef1..3e4df3d6fc65205aae373998616eedc0d36c8d68 100644 (file)
@@ -49,13 +49,14 @@ namespace System.Runtime.Remoting.Activation
                public static IMessage Activate (RemotingProxy proxy, ConstructionCall ctorCall)
                {
                        IMessage response;
+                       ctorCall.SourceProxy = proxy;
 
                        if (Thread.CurrentContext.HasExitSinks && !ctorCall.IsContextOk)
                                response = Thread.CurrentContext.GetClientContextSinkChain ().SyncProcessMessage (ctorCall);
                        else
                                response = RemoteActivate (ctorCall);
 
-                       if (response is IConstructionReturnMessage && ((IConstructionReturnMessage)response).Exception == null)
+                       if (response is IConstructionReturnMessage && ((IConstructionReturnMessage)response).Exception == null && proxy.ObjectIdentity == null)
                        {
                                Identity identity = RemotingServices.GetMessageTargetIdentity (ctorCall);
                                proxy.AttachIdentity (identity);
@@ -167,12 +168,20 @@ namespace System.Runtime.Remoting.Activation
                public static IMessage CreateInstanceFromMessage (IConstructionCallMessage ctorCall)
                {
                        object obj = AllocateUninitializedClassInstance (ctorCall.ActivationType);
-                       ctorCall.MethodBase.Invoke (obj, ctorCall.Args);
 
                        ServerIdentity identity = (ServerIdentity) RemotingServices.GetMessageTargetIdentity (ctorCall);
-
                        identity.AttachServerObject ((MarshalByRefObject) obj, Threading.Thread.CurrentContext);
 
+                       ConstructionCall call = ctorCall as ConstructionCall;
+                       if (ctorCall.ActivationType.IsContextful && call != null && call.SourceProxy != null)
+                       {
+                               call.SourceProxy.AttachIdentity (identity);
+                               MarshalByRefObject target = (MarshalByRefObject) call.SourceProxy.GetTransparentProxy ();
+                               RemotingServices.InternalExecuteMessage (target, ctorCall);
+                       }
+                       else
+                               ctorCall.MethodBase.Invoke (obj, ctorCall.Args);
+
                        return new ConstructionResponse (obj, null, ctorCall);
                }
 
index 88b7010dc8a5a7ac203ec9d3e93ddbb53ad71af0..816442f29a1fcb5cfe2ae14dbee40297d73e04c7 100644 (file)
@@ -1,3 +1,9 @@
+2004-09-22  Lluis Sanchez Gual  <lluis@novell.com>
+
+       * ActivationServices.cs: In Activate, assign the proxy to the ctor
+         message. In CreateInstanceFromMessage if the object being created
+         is a CBO, use the provided proxy as "this" when calling the ctor.
+
 2003-12-23  Lluis Sanchez Gual <lluis@ximian.com>
 
        * ActivationServices.cs: If remote activation returns an exception, do not