[Mono-list] Events using Remoting

Lluis Sanchez lluis@ximian.com
Thu, 02 Dec 2004 11:46:00 +0100


Hi,

The problem is that the delegate is referencing a method of a type that
is no available in the server. When the server tries to deserialize the
delegate, it can't find the referenced type and throws the exception.

In this case, a better option is to use an interface. Create an
interface such as IChannelClient with a mehtod OnMessageChannel,
implement that interface in the client, and then add something like
IChannelHandler.Subscribe (IChannelClient). The server would then call
the OnMessageChannel method of all subscribed clients when needed.

Lluis.

On dt, 2004-11-30 at 12:08 +0100, Andrés Otón wrote:
> Hello,
> 
> I cann't test it at MS.NET. I attach the solutio created with
> monodevelop. The solution is called LinuxMeeting.
> 
> Well, you find inside three projects: Common, Server and Client.
> 
> Common: Used to shared the classes between Server and Client.
> Client: ejem, the client ;-).
> Server: Logicaly the server, sometimes I only say stupid ;-).
> 
> Works:
> - Sever create the static class MainServer and share de Login class.
> - Client get the Login do addUser and call to getServer.
> - With the ServerHandler from getServer, the client create a channel
> and next findChannel to get the ChannelHandler.
> - When client try the event from ChannelHandler get a exception.
> 
> This solution has more classes but you can ignored it. My idea is:
> Class                     |    Class  Shared (MarshalByRefObject)
> Sever                     |        ServerHandler
> Channel                 |        ChannelHandler
> User                       |        UserHandler
> 
> Well, this is a aproximation. And the code is only a test from idea to
> see capabilities.
> 
> Regards.
> 
> 
> On Mon, 29 Nov 2004 11:23:52 +0100, Lluis Sanchez <lluis@ximian.com> wrote:
> > A simple console application that demonstrates the error would be really
> > useful to understand what's the issue.
> > Does it work with MS.NET? if it does, it is probably a bug in mono, and
> > you should file a bug report in bugzilla.ximian.com (including the test
> > case).
> > 
> > Lluis.
> > 
> > 
> > 
> > On dj, 2004-11-25 at 18:06 +0100, Andrés Otón wrote:
> > > Hello,
> > >
> > > I have a problem using events with MarshalByRefObject classes. I explain it:
> > > I have two programs server and client and one lib to share something classes.
> > >
> > > At lib I have the abstract class A : MarshalByRefObject. The server
> > > register at http channel this class and implement it.
> > > The client get this class from server. This class A has a method to
> > > get a second class B, this is public abstract at common lib and
> > > MarshalByRefObject. Well at client I have a delegate, that is declared
> > > type at lib, that link with a method at client. To this point all
> > > works. B has a event and when the client execute:
> > >
> > > b.event += delegate;
> > >
> > > I get a exception error that say Couldn't bind to method 'xxxx', where
> > > the method xxxx is the method of the client that is linked with the
> > > delegate.
> > >
> > > I hope that my problem can be understand because my english is very poor ;-).
> > >
> > > Thanks by all.
> > >
> > 
> > 
> 
>