2003-11-01 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Sat, 1 Nov 2003 18:15:49 +0000 (18:15 -0000)
committerZoltan Varga <vargaz@gmail.com>
Sat, 1 Nov 2003 18:15:49 +0000 (18:15 -0000)
* CrossAppDomainChannel.cs (SyncProcessMessage): Use the new
InvokeInDomain function instead of calling SetDomain.

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

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

index 586e5bdd75cfadcd5dbd9154ee463e4cbdfe7103..4c39596d93c2ac7ac4a81c8f30caf883cc65f73a 100644 (file)
@@ -1,3 +1,8 @@
+2003-11-01  Zoltan Varga  <vargaz@freemail.hu>
+
+       * CrossAppDomainChannel.cs (SyncProcessMessage): Use the new 
+       InvokeInDomain function instead of calling SetDomain.   
+
 2003-10-23  Lluis Sanchez Gual <lluis@ximian.com>
 
        * CrossAppDomainChannel.cs: Before the domain switch, save and reset
index 4cbd740788fe4d0dadd261d58b2fccd61f3fc176..e4c15adff5c581f168da2973c082d4237d8a0d2c 100755 (executable)
@@ -131,6 +131,10 @@ namespace System.Runtime.Remoting.Channels
        internal class CrossAppDomainSink : IMessageSink \r
        {\r
                private static Hashtable s_sinks = new Hashtable();\r
+
+               private static MethodInfo processMessageMethod =
+                       typeof (CrossAppDomainSink).GetMethod ("ProcessMessageInDomain", BindingFlags.NonPublic|BindingFlags.Static);
+
 \r
                private int _domainID;\r
 \r
@@ -156,6 +160,29 @@ namespace System.Runtime.Remoting.Channels
                                }\r
                        }\r
                }
+
+               private struct ProcessMessageRes {
+                       public byte[] arrResponse;
+                       public CADMethodReturnMessage cadMrm;
+               }
+
+               private static ProcessMessageRes ProcessMessageInDomain (
+                       byte[] arrRequest,
+                       CADMethodCallMessage cadMsg)
+           {
+                       ProcessMessageRes res = new ProcessMessageRes ();
+
+                       try 
+                       {
+                               AppDomain.CurrentDomain.ProcessMessageInDomain (arrRequest, cadMsg, out res.arrResponse, out res.cadMrm);
+                       }
+                       catch (Exception e) 
+                       {
+                               IMessage errorMsg = new MethodResponse (e, new ErrorMessage());
+                               res.arrResponse = CADSerializer.SerializeMessage (errorMsg).GetBuffer(); \r
+                       }
+                       return res;
+               }
 \r
                public virtual IMessage SyncProcessMessage(IMessage msgRequest) \r
                {\r
@@ -179,23 +206,19 @@ namespace System.Runtime.Remoting.Channels
 \r
                                object threadStatus = Thread.ResetDataStoreStatus ();\r
                                Context currentContext = Thread.CurrentContext;
-                               AppDomain currentDomain = AppDomain.InternalSetDomainByID ( _domainID );\r
 
-                               try 
-                               {
-                                       AppDomain.CurrentDomain.ProcessMessageInDomain (arrRequest, cadMsg, out arrResponse, out cadMrm);
+                               try {
+                                       // InternalInvoke can't handle out arguments, this is why
+                                       // we return the results in a structure
+                                       ProcessMessageRes res = (ProcessMessageRes)AppDomain.InvokeInDomainByID (_domainID, processMessageMethod, null, new object [] { arrRequest, cadMsg });
+                                       arrResponse = res.arrResponse;
+                                       cadMrm = res.cadMrm;
                                }
-                               catch (Exception e) 
-                               {
-                                       IMessage errorMsg = new MethodResponse (e, new ErrorMessage());
-                                       arrResponse = CADSerializer.SerializeMessage (errorMsg).GetBuffer(); \r
-                               }   
-                               finally 
-                               {
-                                       AppDomain.InternalSetDomain (currentDomain);
+                               finally {
                                        AppDomain.InternalSetContext (currentContext);
-                                       Thread.RestoreDataStoreStatus (threadStatus);\r
-                               }\r
+                                       Thread.RestoreDataStoreStatus (threadStatus);
+                               }                                       
+
                                \r
                                if (null != arrResponse) {\r
                                        // Time to deserialize the message\r
@@ -210,7 +233,6 @@ namespace System.Runtime.Remoting.Channels
                        {\r
                                try\r
                                {\r
-                                       Console.WriteLine("Exception in base domain");
                                        retMessage = new ReturnMessage (e, msgRequest as IMethodCallMessage);
                                }\r
                                catch (Exception)\r