[Mono-list] Remoting with interface definition
Urs Muff
umuff@quark.com
Fri, 14 Mar 2003 16:35:44 -0700
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C2EA82.6E92D5C0
Content-Type: text/plain
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
------_=_NextPart_001_01C2EA82.6E92D5C0
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2653.12">
<TITLE>Remoting with interface definition</TITLE>
</HEAD>
<BODY>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">Using</FONT><FONT =
SIZE=3D2 FACE=3D"Arial"> the following concept is not working on mono, =
but in the MS .Net framework</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">:</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">Common Lib:</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">intercace =
IServerObj</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">{</FONT></P>
<P ALIGN=3DLEFT> <FONT =
SIZE=3D2 FACE=3D"Arial">string Name { get; }</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">}</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">Client:</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">main()</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">{</FONT></P>
<P ALIGN=3DLEFT> <FONT =
SIZE=3D2 FACE=3D"Courier =
New">ChannelServices.RegisterChannel(</FONT><FONT COLOR=3D"#0000FF" =
SIZE=3D2 FACE=3D"Courier New">new</FONT><FONT SIZE=3D2 FACE=3D"Courier =
New"> TcpChannel(</FONT><FONT SIZE=3D2 FACE=3D"Courier =
New">0</FONT><FONT SIZE=3D2 FACE=3D"Courier New">));</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">IServerObject server =
=3D</FONT> <FONT SIZE=3D2 =
FACE=3D"Arial">Activation.GetObject(typeof(IServerObj),</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">"</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">tcp://localhost:8085/Test</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">"</FONT><FONT SIZE=3D2 FACE=3D"Arial">) as =
IServerObject;</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">string name =3D =
server.Name;</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">}</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">Server:</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">class ServerObject =
:</FONT> <FONT SIZE=3D2 FACE=3D"Arial">MarshalByRefObject,</FONT> <FONT =
SIZE=3D2 FACE=3D"Arial">IServerObject</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">{</FONT></P>
<P ALIGN=3DLEFT> <FONT =
SIZE=3D2 FACE=3D"Arial">public string Name { get { return</FONT> <FONT =
SIZE=3D2 FACE=3D"Arial">"</FONT><FONT SIZE=3D2 FACE=3D"Arial">Test =
Server</FONT><FONT SIZE=3D2 FACE=3D"Arial">"</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">; } }</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">}</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">main()</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">{</FONT></P>
<P ALIGN=3DLEFT> <FONT =
SIZE=3D2 FACE=3D"Courier =
New">ChannelServices.RegisterChannel(</FONT><FONT COLOR=3D"#0000FF" =
SIZE=3D2 FACE=3D"Courier New">new</FONT><FONT SIZE=3D2 FACE=3D"Courier =
New"> TcpChannel(8085));</FONT></P>
<P ALIGN=3DLEFT> <FONT =
SIZE=3D2 FACE=3D"Courier =
New">RemotingConfiguration.RegisterWellKnownServiceType(</FONT><FONT =
COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Courier New">typeof</FONT><FONT =
SIZE=3D2 FACE=3D"Courier New">(HelloServer),"</FONT><FONT SIZE=3D2 =
FACE=3D"Courier New">Test</FONT><FONT SIZE=3D2 FACE=3D"Courier =
New">",WellKnownObjectMode.Singleton);</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">}</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">This is a very important =
concept, since it allows hiding the</FONT> <FONT SIZE=3D2 =
FACE=3D"Arial">implementation</FONT><FONT SIZE=3D2 FACE=3D"Arial"> from =
the Client.</FONT></P>
<P ALIGN=3DLEFT><FONT SIZE=3D2 FACE=3D"Arial">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).</FONT> <FONT SIZE=3D2 FACE=3D"Arial"> 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?]).</FONT> <FONT SIZE=3D2 =
FACE=3D"Arial"> I</FONT><FONT SIZE=3D2 FACE=3D"Arial">'</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">m not that familiar with the mono remoting =
implementation, but that seems like a design problem, unless =
I</FONT><FONT SIZE=3D2 FACE=3D"Arial">'</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">m doing something wrong.</FONT></P>
<P ALIGN=3DLEFT><B></B><A NAME=3D"_MailAutoSig"><B><FONT =
COLOR=3D"#003300" SIZE=3D2 FACE=3D"Garamond">- Urs C. =
Muff</FONT></B></A></P>
<P ALIGN=3DLEFT><FONT COLOR=3D"#003300" SIZE=3D2 =
FACE=3D"Garamond">Systems Architect </FONT><B></B><B> =
<FONT COLOR=3D"#003300" SIZE=3D2 FACE=3D"Garamond">- =
Research Lab</FONT></B></P>
<P ALIGN=3DLEFT></P>
</BODY>
</HTML>
------_=_NextPart_001_01C2EA82.6E92D5C0--