[Mono-bugs] [Bug 53020][Maj] New - Remoting Interop between Microsoft CLR 1.0 on Windows and Mono on Linux with AsyncDelegates
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sun, 18 Jan 2004 07:48:57 -0500 (EST)
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 matt.davey@finetix.com.
http://bugzilla.ximian.com/show_bug.cgi?id=53020
--- shadow/53020 2004-01-18 07:48:57.000000000 -0500
+++ shadow/53020.tmp.30890 2004-01-18 07:48:57.000000000 -0500
@@ -0,0 +1,133 @@
+Bug#: 53020
+Product: Mono/Runtime
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Major
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: matt.davey@finetix.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Remoting Interop between Microsoft CLR 1.0 on Windows and Mono on Linux with AsyncDelegates
+
+Please fill in this template when reporting a bug, unless you know what
+you are doing.
+Description of Problem:
+
+Invoking a client callback from server to client via an Async delegate
+generates this error on Mono:
+
+System.InvalidCastException: Cannot cast from source type to destination
+type
+in <0x0005b> servicecomlib.HelloServer:callback (System.IAsyncResult)
+
+However the method appears to be successfully called on the client.
+
+
+Steps to reproduce the problem:
+1. Call a client method via an AsyncDelegate from the server. Example
+code as follows:
+
+public class ClientCallback : MarshalByRefObject, IClientCallback
+{
+public void Send(ArrayList al)
+{
+Console.WriteLine("ClientCallback.Send was called");
+foreach (object o in al)
+{
+ Console.WriteLine("\t" + o);
+}
+}
+}
+
+static void Main(string[] args)
+{
+string svr = "tcp://"+ args[0] + ":8085/Test.rem";
+ChannelServices.RegisterChannel(new TcpChannel(0));
+IServerObject s = Activator.GetObject(typeof(IServerObject),svr) as
+IServerObject;
+ClientCallback c = new ClientCallback();
+Console.WriteLine("Passing client object to server");
+s.CallClient(c);
+}
+
+
+server code:
+
+static void Main(string[] args)
+{
+ChannelServices.RegisterChannel(new TcpChannel(8085));
+RemotingConfiguration.RegisterWellKnownServiceType(typeof
+(servicecomlib.HelloServer),"Test.rem", WellKnownObjectMode.Singleton);
+Console.ReadLine();
+}
+
+public delegate void crap(ArrayList al);
+
+public class HelloServer: MarshalByRefObject , IServerObject
+{
+ public HelloServer()
+ {
+ Console.WriteLine("HelloServer constructor");
+ }
+
+ public void CallClient(IClientCallback c)
+ {
+ ArrayList al = new ArrayList();
+ al.Add("one");
+ al.Add("two");
+
+ Console.WriteLine("Now doing async callback");
+ crap a = new crap(c.Send);
+ a.BeginInvoke(al, new AsyncCallback(callback), null);
+ }
+
+ private void callback(IAsyncResult a)
+ {
+ try
+ {
+ crap Caller = (crap)((AsyncResult)
+a).AsyncDelegate;
+ Caller.EndInvoke(a);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.ToString());
+ }
+ }
+}
+
+2. In the "callback" method above, the cast appears to fail, generating
+this error message:
+
+System.InvalidCastException: Cannot cast from source type to destination
+type
+in <0x0005b> servicecomlib.HelloServer:callback (System.IAsyncResult)
+
+3. If the client remoting method is tagged with
+[System.Runtime.Remoting.Messaging.OneWay], then the exception does not
+to happen
+
+Actual Results:
+
+System.InvalidCastException: Cannot cast from source type to destination
+type
+in <0x0005b> servicecomlib.HelloServer:callback (System.IAsyncResult)
+
+
+Expected Results:
+
+Client method should be called by the server and no exception should be
+generateed
+
+How often does this happen?
+
+Always
+
+Additional Information: