[IronPython] Remoting: Marshal object

Ralph Soons ralph.soons.asml at hotmail.com
Wed Jun 21 09:49:12 CEST 2006

In c# I have 3 assembly's. There's a server exe and a client exe and a 
library in which the remoting objects are implemented, which are included in 
both the client and the server. The CallbackSink class is situated in the 
library which has the namespace RemotingServerClient.
I use server activated Singleton mode configuration.

I would like to register on the OnHostToClient event at server side so any 
object registering for this event receives a notification when a client 
calls. My problem was that the object I registered my event to and the 
object which was called by the client weren't the same. So my registered 
event handlers weren't called. That's why I had to use the marshal function. 
Using the c# server and client this works.

After this I replaced the c# server by a python server. I used the same 
configuration. Created an event handler function. Created the CallbackSink 
object (got an instance) and registered the event handler to it. Now I 
marshal the callbacksink object to make sure during a call from the client 
the same object is used.

When I call my server in python from the c# client, the message is received 
in the Send function of the CallbackSink and if write the received message 
to the console I see the message appearing in the python console. However 
the CallbackSink object is newly created and isn't the object I marshalled 
in the python server.

So it looks like the Marshal call doesn't work. I don't see any exception. 
Only thing I see is that the objects are different.

>From: Dino Viehland <dinov at exchange.microsoft.com>
>Reply-To: Discussion of IronPython <users at lists.ironpython.com>
>To: Discussion of IronPython <users at lists.ironpython.com>
>Subject: Re: [IronPython] Remoting: Marshal object
>Date: Tue, 20 Jun 2006 09:05:07 -0700
>I'm a little lost on this one - what is RemotingServerClient here?  Is it a 
>type, an assembly, a namespace?
>Also, do you get an exception, or does it just do nothing?
>-----Original Message-----
>From: users-bounces at lists.ironpython.com 
>[mailto:users-bounces at lists.ironpython.com] On Behalf Of Ralph Soons
>Sent: Tuesday, June 20, 2006 8:04 AM
>To: users at lists.ironpython.com
>Subject: [IronPython] Remoting: Marshal object
>I have a remoting problem again. I want to create an object at server side, 
>as singleton so when a call is done at client side, ill get the already 
>existing object. I tried it first with a c# server and client.
>Can anyone tell me why the marshal function doesn't work, objects on server 
>and client side are still different (same code works in c# application so 
>configuration is correct):
>Client side (Python):
>t = RemotingServerClient.CallbackSink.Instance
>System.Runtime.Remoting.RemotingServices.Marshal(t, 'TalkIsGoodToo')
>Server side (c#):
>Remotable object (c#):
>public class CallbackSink : MarshalByRefObject
>     {
>         private static CallbackSink m_Instance = null;
>         public event delCommsInfo OnHostToClient;
>         public static CallbackSink Instance
>         {
>             get
>             {
>                 if (null == m_Instance)
>                 {
>                     m_Instance = new CallbackSink();
>                 }
>                 return m_Instance;
>             }
>         }
>         private CallbackSink()
>         { }
>         public void Send(string message)
>         {
>             OnHostToClient(info);
>         }
>     }
>Thanks for your help.
>Best regards,
>Ralph Soons
>Talk with your online friends with MSN Messenger 
>users mailing list
>users at lists.ironpython.com
>users mailing list
>users at lists.ironpython.com

Talk with your online friends with MSN Messenger 

More information about the Ironpython-users mailing list