[Mono-dev] Remoting - can't pass an object reference in call between windows and mono.

Steffen Enni steffen.enni at gmail.com
Tue Sep 2 05:31:08 EDT 2008


Hi,

My client implements a callback interface that is supplied as an argument to
a remote call against a server.

The interface is:

    public interface IHello
    {
        //client -----(SayHello)-----> server
        //       <-----(Hello)--------
        //       ---return(Hello)---->
        //       <--return(SayHello)--
        void SayHello(string sender, IHello remoteRef);
        void Hello(string sender);
    }

When I run both server and client on windows then calling SayHello() works.
Similarly when running on mono 2.1.r110365 (the VMWare image with the latest
build from http://www.mono-project.de/mono-image/) it also works.  If I just
call the Hello() method then it works in all cases.

I've attached a combined MonoDevelop / Visual Studio 2008 solution which can
reproduce the behavior.

I set up the HttpChannel in the following way on both the server and client:
  BinaryServerFormatterSinkProvider serverProv = new
BinaryServerFormatterSinkProvider();
  serverProv.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
  BinaryClientFormatterSinkProvider clientProv = new
BinaryClientFormatterSinkProvider();
  System.Collections.IDictionary props = new System.Collections.Hashtable();
  props["port"] = 7326;
  HttpChannel channel = new HttpChannel(props, clientProv, serverProv);
  ChannelServices.RegisterChannel(channel, false);

I activate the IHello implementations on both the client and server using
code like this:

 class HelloImpl : MarshalByRefObject, IHello { ...}
 HelloImpl hello = new HelloImpl();
 RemotingServices.Marshal(hello, "server");


I've tested on the following combinations using a HttpChannel. I've tried
using a TcpChannel with similar results and now I'm run out of ideas of what
to try.

==========================================
Server            Client            Result
mono 1.9.1        mono 1.9.1          FAIL
mono 1.9.1        mono 2.1.r110365      OK
mono 1.9.1        windows             FAIL
mono 2.1-r110365  mono 2.1-r110365      OK
mono 2.1.r110365  mono 1.9.1          FAIL
mono 2.1-r110365  windows             FAIL   <=== This is the one I would
like to see working.
windows           mono 1.9.1          FAIL
windows           mono 2.1-r110365    FAIL
windows           windows               OK
===========================================

I get different failure scenarios. (They can all be seen in the notes.txt
file that are included in the attached archive.)

When the client is on windows (a Vista machine, tried both with .NET 3.5 and
2.0 with same result) I get the following error on the client side:

Server stack trace:
  at System.Reflection.MonoField.SetValue (System.Object obj, System.Object
val, BindingFlags invokeAttr, System.Reflection.Binder binder, Syste
m.Globalization.CultureInfo culture) [0x00000]
  at System.Reflection.FieldInfo.SetValue (System.Object obj, System.Object
value) [0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.SetObjectValue
(System.Object parentObject, System.String fieldName, System.Ref
lection.MemberInfo memberInfo,
System.Runtime.Serialization.SerializationInfo info, System.Object value,
System.Type valueType, System.Int32[] i
ndices) [0x00000]
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadValue
(System.IO.BinaryReader reader, System.Object parentObject, Int64 par
entObjectId, System.Runtime.Serialization.SerializationInfo info,
System.Type valueType, System.String fieldName, System.Reflection.MemberInfo
m
emberInfo, System.Int32[] indices) [0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectContent
(System.IO.BinaryReader reader, System.Runtime.Serialization.
Formatters.Binary.TypeMetadata metadata, Int64 objectId, System.Object&
objectInstance, System.Runtime.Serialization.SerializationInfo& info) [0
x00000]
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectInstance
(System.IO.BinaryReader reader, Boolean isRuntimeObject, Boo
lean hasTypeInfo, System.Int64& objectId, System.Object& value,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
  at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObject
(BinaryElement element, System.IO.BinaryReader reader, System.Int64&
 objectId, System.Object& value,
System.Runtime.Serialization.SerializationInfo& info) [0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadNextObject
(System.IO.BinaryReader reader) [0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.ObjectReader.ReadObjectGraph
(System.IO.BinaryReader reader, Boolean readHeaders, System.Obj
ect& result, System.Runtime.Remoting.Messaging.Header[]& headers) [0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.MessageFormatter.ReadMethodCall
(System.IO.BinaryReader reader, Boolean hasHeaders, System.R
untime.Remoting.Messaging.HeaderHandler headerHandler,
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter formatter)
[0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.NoCheckDeserialize
(System.IO.Stream serializationStream, System.Runtime.Rem
oting.Messaging.HeaderHandler handler) [0x00000]
  at
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize
(System.IO.Stream serializationStream, System.Runtime.Remoting.M
essaging.HeaderHandler handler) [0x00000]
  at
System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage
(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITranspo
rtHeaders requestHeaders, System.IO.Stream requestStream, IMessage&
responseMsg, ITransportHeaders& responseHeaders, System.IO.Stream& responseS
tream) [0x00000]

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
   at Interface.IHello.SayHello(String sender, IHello remoteRef)
   at Client.Program.Main(String[] args) in
D:\Projects\Constellation\mono\PassingObjRef\Client\Program.cs:line 51


I've searched the mailing list archive and could not find any hints on what
to do, so I have no idea of what else I could try to solve this problem.

Is there a kind person that is able to help me in solving this problem?


Best regards

Steffen Enni
Denmark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080902/a831e8c4/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PassingObjRef.tar.gz
Type: application/x-gzip
Size: 6404 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080902/a831e8c4/attachment-0001.gz 


More information about the Mono-devel-list mailing list