[Mono-list] Remoting with interface definition

Lluis Sanchez lluis@ideary.com
Sun, 16 Mar 2003 13:51:29 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_000C_01C2EBC3.25715690
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Remoting with interface definitionHi!

I also have a patch for this. It will be ready in a couple of days.=20

- Lluis.

----- Original Message -----=20
  From: Urs Muff=20
  To: 'mono-list@lists.ximian.com'=20
  Sent: Saturday, March 15, 2003 12: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 =3D =
Activation.GetObject(typeof(IServerObj),"tcp://localhost:8085/Test") as =
IServerObject;

  string name =3D server.Name;

  }

  Server:

  class ServerObject : MarshalByRefObject, IServerObject

  {

          public string Name { get { return "Test Server"; } }

  }

  main()

  {

          ChannelServices.RegisterChannel(new TcpChannel(8085));

          =
RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloServer),"T=
est",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_000_000C_01C2EBC3.25715690
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>Remoting with interface definition</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1141" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I also have a patch for this. It will =
be ready in a=20
couple of days. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>- Lluis.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>----- Original Message ----- </DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dumuff@quark.com href=3D"mailto:umuff@quark.com">Urs =
Muff</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A =
title=3Dmono-list@lists.ximian.com=20
  =
href=3D"mailto:'mono-list@lists.ximian.com'">'mono-list@lists.ximian.com'=
</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Saturday, March 15, 2003 =
12:35=20
  AM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Mono-list] Remoting =
with=20
  interface definition</DIV>
  <DIV><BR></DIV>
  <P align=3Dleft><FONT face=3DArial size=3D2>Using</FONT><FONT =
face=3DArial size=3D2> the=20
  following concept is not working on mono, but in the MS .Net=20
  framework</FONT><FONT face=3DArial size=3D2>:</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>Common Lib:</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>intercace =
IServerObj</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>{</FONT></P>
  <P align=3Dleft>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
face=3DArial=20
  size=3D2>string Name { get; }</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>}</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>Client:</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>main()</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>{</FONT></P>
  <P align=3Dleft>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT=20
  face=3D"Courier New" =
size=3D2>ChannelServices.RegisterChannel(</FONT><FONT=20
  face=3D"Courier New" color=3D#0000ff size=3D2>new</FONT><FONT =
face=3D"Courier New"=20
  size=3D2> TcpChannel(</FONT><FONT face=3D"Courier New" =
size=3D2>0</FONT><FONT=20
  face=3D"Courier New" size=3D2>));</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>IServerObject server =
=3D</FONT> <FONT=20
  face=3DArial =
size=3D2>Activation.GetObject(typeof(IServerObj),</FONT><FONT=20
  face=3DArial size=3D2>"</FONT><FONT face=3DArial=20
  size=3D2>tcp://localhost:8085/Test</FONT><FONT face=3DArial =
size=3D2>"</FONT><FONT=20
  face=3DArial size=3D2>) as IServerObject;</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>string name =3D =
server.Name;</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>}</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>Server:</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>class ServerObject =
:</FONT> <FONT=20
  face=3DArial size=3D2>MarshalByRefObject,</FONT> <FONT face=3DArial=20
  size=3D2>IServerObject</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>{</FONT></P>
  <P align=3Dleft>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT =
face=3DArial=20
  size=3D2>public string Name { get { return</FONT> <FONT face=3DArial=20
  size=3D2>"</FONT><FONT face=3DArial size=3D2>Test Server</FONT><FONT =
face=3DArial=20
  size=3D2>"</FONT><FONT face=3DArial size=3D2>; } }</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>}</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>main()</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>{</FONT></P>
  <P align=3Dleft>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT=20
  face=3D"Courier New" =
size=3D2>ChannelServices.RegisterChannel(</FONT><FONT=20
  face=3D"Courier New" color=3D#0000ff size=3D2>new</FONT><FONT =
face=3D"Courier New"=20
  size=3D2> TcpChannel(8085));</FONT></P>
  <P align=3Dleft>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT=20
  face=3D"Courier New"=20
  =
size=3D2>RemotingConfiguration.RegisterWellKnownServiceType(</FONT><FONT =

  face=3D"Courier New" color=3D#0000ff size=3D2>typeof</FONT><FONT =
face=3D"Courier New"=20
  size=3D2>(HelloServer),"</FONT><FONT face=3D"Courier New" =
size=3D2>Test</FONT><FONT=20
  face=3D"Courier New" =
size=3D2>",WellKnownObjectMode.Singleton);</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>}</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>This is a very important =
concept, since=20
  it allows hiding the</FONT> <FONT face=3DArial =
size=3D2>implementation</FONT><FONT=20
  face=3DArial size=3D2> from the Client.</FONT></P>
  <P align=3Dleft><FONT face=3DArial size=3D2>The crash is in corlib :=20
  Remoting.TypeInfo (since it assumes to be derived from object or=20
  MarshalByRefObject, which it is not, since it is a pure=20
  interface).</FONT>&nbsp;<FONT face=3DArial size=3D2> Fixing that does =
not help=20
  either since it crashes later than, since it still assumes it has to =
be a=20
  MarshalByRefObject (which it eventually should be since it will become =
a Proxy=20
  [right?]).</FONT>&nbsp;<FONT face=3DArial size=3D2> I</FONT><FONT =
face=3DArial=20
  size=3D2>'</FONT><FONT face=3DArial size=3D2>m not that familiar with =
the mono=20
  remoting implementation, but that seems like a design problem, unless=20
  I</FONT><FONT face=3DArial size=3D2>'</FONT><FONT face=3DArial =
size=3D2>m doing=20
  something wrong.</FONT></P>
  <P align=3Dleft><B></B><A name=3D_MailAutoSig><B><FONT face=3DGaramond =
color=3D#003300=20
  size=3D2>- Urs C. Muff</FONT></B></A></P>
  <P align=3Dleft><FONT face=3DGaramond color=3D#003300 size=3D2>Systems =

  Architect&nbsp;&nbsp;</FONT><B></B><B> &nbsp;&nbsp;&nbsp; <FONT =
face=3DGaramond=20
  color=3D#003300 size=3D2>- Research Lab</FONT></B></P>
  <P align=3Dleft></P></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_000C_01C2EBC3.25715690--