[Mono-bugs] [Bug 60427][Nor] New - exception thrown in remoting if interface parameter names differ from the impelmentation method parameter names

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Fri, 18 Jun 2004 10:53:17 -0400 (EDT)


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by y.leikind@sam-solutions.net.

http://bugzilla.ximian.com/show_bug.cgi?id=60427

--- shadow/60427	2004-06-18 10:53:17.000000000 -0400
+++ shadow/60427.tmp.18533	2004-06-18 10:53:17.000000000 -0400
@@ -0,0 +1,151 @@
+Bug#: 60427
+Product: Mono: Class Libraries
+Version: unspecified
+OS: 
+OS Details: Linux pc324 2.4.18-686
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: y.leikind@sam-solutions.net               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: exception thrown in remoting if interface parameter names differ from the impelmentation method parameter names
+
+If I have a server that exposes some type via remoting, and 
+this type implements an interface with the help of which
+the type is accessed in the remoting client, the parameter names
+in interface methods declarations influence runtime. 
+
+In other words, if the parameters names are not the same,
+the call to the remote object will raise an exception.
+
+Here is the code for you to believe me:
+
+==========     IFactorial.cs   ==========
+
+namespace ProofOfConcepts{
+    public interface IFactorial{
+        //ulong CalculateFactorial(uint a);  // With this line everything 
+works
+        ulong CalculateFactorial(uint b);    // With this line it doesn't
+    }
+}
+
+
+==========     Server.cs   ==========
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Http;
+
+namespace ProofOfConcepts{
+    
+    public class Calculator : MarshalByRefObject, IFactorial{
+        public ulong CalculateFactorial(uint a){
+            ulong res = 1;
+            for (uint i=1 ; i<=a; i++)
+                res = res * i;
+            Console.WriteLine("!{0} = {1}", a, res);
+            return res;
+        }
+    }
+    
+    class Server{
+        public Server(){
+            HttpChannel channel = new HttpChannel(60000);
+            ChannelServices.RegisterChannel(channel);
+            Type facType = Type.GetType("ProofOfConcepts.Calculator");
+            RemotingConfiguration.RegisterWellKnownServiceType(
+                facType,
+                "MyEndPoint",
+                WellKnownObjectMode.Singleton );            
+        }
+        
+        void Listen(){
+            Console.WriteLine("Press Enter to exit...");
+            Console.ReadLine( );
+        }
+        
+        public static void Main(){
+            new Server().Listen();
+        }
+    }
+
+}
+
+==========     Client.cs   ==========
+
+using System;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+using System.Runtime.Remoting.Channels.Http;
+
+
+namespace ProofOfConcepts{
+    class Client{
+        public static void Main(){
+            HttpChannel channel = new HttpChannel(0);
+            ChannelServices.RegisterChannel(channel);
+            MarshalByRefObject obj = 
+                (MarshalByRefObject) RemotingServices.Connect(
+                    typeof(ProofOfConcepts.IFactorial),
+                    "http://localhost:60000/MyEndPoint");
+            IFactorial cal = (IFactorial) obj;
+            Console.WriteLine("!4 = {0}", cal.CalculateFactorial(4));
+        }
+    }
+}
+
+==============================
+
+To compile these, issue the following commands:
+
+mcs   /t:library /out:IFactorial.dll IFactorial.cs
+
+mcs  /r:IFactorial.dll,System.Runtime.Remoting.dll  /out:Server.exe Server.cs
+
+mcs  /r:IFactorial.dll,System.Runtime.Remoting.dll  /out:Client.exe Client.cs
+
+
+Now run the server, then start the client.
+
+I get the following in the Client.exe console::
+
+===============================
+
+leikind@pc324:~/cs/appDomains/my_remoting$ mono Client.exe 
+
+Unhandled Exception: System.IndexOutOfRangeException: Array index is out of
+range.
+
+Server stack trace: 
+in <0x005ea>
+System.Runtime.Remoting.Channels.SoapMessageFormatter:BuildMethodCallFromSoapMessage
+(System.Runtime.Serialization.Formatters.SoapMessage,string)
+in <0x001f5>
+System.Runtime.Remoting.Channels.SoapServerFormatterSink:ProcessMessage
+(System.Runtime.Remoting.Channels.IServerChannelSinkStack,System.Runtime.Remoting.Messaging.IMessage,System.Runtime.Remoting.Channels.ITransportHeaders,System.IO.Stream,System.Runtime.Remoting.Messaging.IMessage&,System.Runtime.Remoting.Channels.ITransportHeaders&,System.IO.Stream&)
+
+
+Exception rethrown at [0]: 
+
+in <0x00748> System.Runtime.Remoting.Proxies.RealProxy:PrivateInvoke
+(System.Runtime.Remoting.Proxies.RealProxy,System.Runtime.Remoting.Messaging.IMessage,System.Exception&,object[]&)
+
+===============================
+
+If you cache in the interface  line 
+	ulong CalculateFactorial(uint b);  
+to
+	ulong CalculateFactorial(uint a);  
+recompile all the three assemblies, and run again, everything will work
+just fine.
+
+I run Mono 0.95
+
+On MS .NET it works fine in all cases