[Mono-list] Remoting with interface definition

Lluis Sanchez lluis@ideary.com
Mon, 31 Mar 2003 16:28:47 +0200


Remoting with interface definitionThis should work now.

----- Original Message -----
From: Urs Muff
To: 'mono-list@lists.ximian.com'
Sent: Saturday, March 15, 2003 1:35 AM
Subject: [Mono-list] Remoting with interface definition


Using the following concept is not working on mono, but in the MS .Net
framework:
Common Lib:
intercace IServerObj
{
        string Name { get; }
}
Client:
main()
{
        ChannelServices.RegisterChannel(new TcpChannel(0));
IServerObject server =
Activation.GetObject(typeof(IServerObj),"tcp://localhost:8085/Test") as
IServerObject;
string name = server.Name;
}
Server:
class ServerObject : MarshalByRefObject, IServerObject
{
        public string Name { get { return "Test Server"; } }
}
main()
{
        ChannelServices.RegisterChannel(new TcpChannel(8085));

RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloServer),"Test
",WellKnownObjectMode.Singleton);
}
This is a very important concept, since it allows hiding the implementation
from the Client.
The crash is in corlib : Remoting.TypeInfo (since it assumes to be derived
from object or MarshalByRefObject, which it is not, since it is a pure
interface).  Fixing that does not help either since it crashes later than,
since it still assumes it has to be a MarshalByRefObject (which it
eventually should be since it will become a Proxy [right?]).  I'm not that
familiar with the mono remoting implementation, but that seems like a design
problem, unless I'm doing something wrong.
- Urs C. Muff
Systems Architect       - Research Lab