2003-03-15 Lluis Sanchez Gual <lluis@ideary.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 15 Mar 2003 16:34:21 +0000 (16:34 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Sat, 15 Mar 2003 16:34:21 +0000 (16:34 -0000)
* System/AppDomain.cs:
* System.Runtime.Remoting/RemotingServices.cs:
* System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs: fixes bugs
#39380 and #39331.

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

mcs/class/corlib/System.Runtime.Remoting.Channels/ChangeLog
mcs/class/corlib/System.Runtime.Remoting.Channels/CrossAppDomainChannel.cs
mcs/class/corlib/System.Runtime.Remoting/ChangeLog
mcs/class/corlib/System.Runtime.Remoting/RemotingServices.cs
mcs/class/corlib/System/AppDomain.cs
mcs/class/corlib/System/ChangeLog

index 7b5183f17101d3f9f40a42ea5c68cfafc34f2813..bb458b820b39c7c3f0ec1fcc999ef5e43793fbfb 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-15  Lluis Sanchez Gual <lluis@ideary.com>
+
+       * CrossAppDomainChannel.cs: fixes bugs #39380 and #39331.
+
 2003-03-03  Lluis Sanchez Gual  <lluis@ideary.com>
 
        * ChannelServices.cs: Minor corrections.
index 5b8a62b857cb8244ef7763b893dc04097efc10e3..e900b284d5e19dd8ec2f838f66ff8b3abfb22d5f 100755 (executable)
@@ -173,21 +173,7 @@ namespace System.Runtime.Remoting.Channels
 
                                try 
                                {
-                                       IMessage reqDomMsg;
-
-                                       if (null != arrRequest)
-                                               reqDomMsg = CADSerializer.DeserializeMessage (new MemoryStream(arrRequest), null);
-                                       else
-                                               reqDomMsg = new MethodCall (cadMsg);
-
-                                       IMessage retDomMsg = ChannelServices.SyncDispatchMessage (reqDomMsg);
-
-                                       cadMrm = CADMethodReturnMessage.Create (retDomMsg);
-                                       if (null == cadMrm) {
-                                               arrResponse = CADSerializer.SerializeMessage (retDomMsg).GetBuffer();
-                                       } else
-                                               arrResponse = null;
-\r
+                                       AppDomain.CurrentDomain.ProcessMessageInDomain (arrRequest, cadMsg, out arrResponse, out cadMrm);
                                }
                                catch (Exception e) 
                                {
index 47333dbc4104d7b6f285bf01d66552a27af95022..2474c7d0cda2c575e11b997e4495d9dc869015c4 100755 (executable)
@@ -1,3 +1,7 @@
+2003-03-15  Lluis Sanchez Gual <lluis@ideary.com>
+
+       * RemotingServices.cs: fixes bugs #39380 and #39331.
+
 2003-02-25 Lluis Sanchez Gual <lluis@ideary.com>
 
        * Identity.cs: Added property to check if an identity is connected (it is remotely accesible)
index 017ab0c5035d75bb3961c95f1b14b11323eb1e9c..f600722e555186e4240ee900832eaf71ae28c46f 100644 (file)
@@ -21,6 +21,7 @@ using System.Runtime.Remoting.Activation;
 using System.Runtime.Remoting.Lifetime;
 using System.Runtime.CompilerServices;
 using System.Runtime.Serialization;
+using System.IO;
 
 namespace System.Runtime.Remoting
 {
@@ -34,8 +35,8 @@ namespace System.Runtime.Remoting
                
                static RemotingServices ()
                {
+                       RegisterInternalChannels ();
                        app_id = "/" + Guid.NewGuid().ToString().Replace('-', '_') + "/";
-
                        CreateWellKnownServerIdentity (typeof(RemoteActivator), "RemoteActivationService.rem", WellKnownObjectMode.Singleton);
                }
        
@@ -449,26 +450,23 @@ namespace System.Runtime.Remoting
 
                internal static object GetDomainProxy(AppDomain domain) 
                {
-                       ObjRef appRef = null;
-
-                       // Make sure that the channels is active in this domain
-                       RegisterInternalChannels();
+                       byte[] data = null;
 
-                       // this should use contexts in the future
+                       Context currentContext = Thread.CurrentContext;
                        AppDomain currentDomain = AppDomain.InternalSetDomain (domain);
                        try 
                        {
-                               // Make sure that our new domain also has the internal channels
-                               RegisterInternalChannels();
-
-                               appRef = RemotingServices.Marshal(domain, null, null);
+                               data = domain.GetMarshalledDomainObjRef ();
                        }
                        finally 
                        {
                                AppDomain.InternalSetDomain (currentDomain);
+                               AppDomain.InternalSetContext (currentContext);
                        }
 
-                       return (AppDomain) RemotingServices.Unmarshal(appRef);
+                       MemoryStream stream = new MemoryStream (data);
+                       ObjRef appref = (ObjRef) CADSerializer.DeserializeObject (stream);
+                       return (AppDomain) RemotingServices.Unmarshal(appref);
                }
 
                private static void RegisterInternalChannels() 
index d5a52282b5fa070d8de588b36909867d80bb9b63..edfd0bfe873fb0bfa25de0678da12292367f1773 100755 (executable)
@@ -22,6 +22,8 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.Remoting;
 using System.Runtime.Remoting.Contexts;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Messaging;
 using System.Security.Principal;
 using System.Security.Policy;
 using System.Security;
@@ -694,6 +696,33 @@ namespace System {
 
                        return null;
                }
+
+               internal byte[] GetMarshalledDomainObjRef ()
+               {
+                       ObjRef oref = RemotingServices.Marshal(AppDomain.CurrentDomain, null, typeof(AppDomain));
+                       return CADSerializer.SerializeObject (oref).GetBuffer();
+               }
+
+               internal void ProcessMessageInDomain (byte[] arrRequest, CADMethodCallMessage cadMsg, out byte[] arrResponse, out CADMethodReturnMessage cadMrm)
+               {
+                       IMessage reqDomMsg;
+
+                       if (null != arrRequest)
+                               reqDomMsg = CADSerializer.DeserializeMessage (new MemoryStream(arrRequest), null);
+                       else
+                               reqDomMsg = new MethodCall (cadMsg);
+
+                       IMessage retDomMsg = ChannelServices.SyncDispatchMessage (reqDomMsg);
+
+                       cadMrm = CADMethodReturnMessage.Create (retDomMsg);
+                       if (null == cadMrm) 
+                       {
+                               arrResponse = CADSerializer.SerializeMessage (retDomMsg).GetBuffer();
+                       } 
+                       else
+                               arrResponse = null;
+               }
+
                // End of methods called from the runtime
                
                public event AssemblyLoadEventHandler AssemblyLoad;
index 725d08d0743bb7967543aa4f2e424eb87786cd53..93c0f8a5e542d4f761b5f71cc3c69d8e7e362577 100644 (file)
@@ -1,3 +1,7 @@
+2003-03-15  Lluis Sanchez Gual <lluis@ideary.com>
+
+       * AppDomain.cs: fixes bugs #39380 and #39331.
+
 2003-03-06  Nick Drochak  <ndrochak@gol.com>
 
        * TimeSpan.cs (Negate): Throw exception when value is MinValue.