"Quin" <QuinP@dennisusa.com> wrote in news:eODRt$kZGHA.4248
@TK2MSFTNGP05.phx.gbl:
> I have a client that creates a remoteable server object,
> "serverobject", and can pass strings. The client creates
> a "clientobject" to pass to the server, as:
>
> serverobject.pass(clientobject)
Did you inherit MarshalObjectByRef in the client object?
Also, is the client object delcare in a common interface shared by
client/server?
Quin - 23 Apr 2006 20:44 GMT
> "Quin" <QuinP@dennisusa.com> wrote in news:eODRt$kZGHA.4248
> @TK2MSFTNGP05.phx.gbl:
[quoted text clipped - 9 lines]
> Also, is the client object delcare in a common interface shared by
> client/server?
Yes, the client object inherits MarhsalObjectByRef. The
Server project has a reference to the client project.
Quin - 23 Apr 2006 23:25 GMT
> "Quin" <QuinP@dennisusa.com> wrote in news:eODRt$kZGHA.4248
> @TK2MSFTNGP05.phx.gbl:
[quoted text clipped - 9 lines]
> Also, is the client object delcare in a common interface shared by
> client/server?
Both projects reference each other and System.Remoting
Here is the Client Code:
using System;
using System.Collections.Generic;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using HServer;
namespace HClient
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("HClient");
//Create the Channel, Register
TcpChannel clientChannel = new TcpChannel();
ChannelServices.RegisterChannel(clientChannel, false);
//Register for Remote Object
WellKnownClientTypeEntry remoteType = new
WellKnownClientTypeEntry(
typeof(HelloServer),
"tcp://localhost:9090/HelloServer");
RemotingConfiguration.RegisterWellKnownClientType(remoteType);
//Create Remote object and call
HelloServer hs = new HelloServer();
hs.SendString("String from HClient"); //Send String
Console.WriteLine("String sent, hit any key to continue");
Console.Read();
//Create obj and send
HelloClient hc = new HelloClient();
hs.SendObj(hc);
Console.WriteLine("HClient, waiting to exit, hit any key");
Console.Read();
}
}
public class HelloClient : MarshalByRefObject
{
public void ReceiveString(string myString)
{
Console.WriteLine(myString);
}
}
}

Signature
Here is the Server Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using HClient;
namespace HServer
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("HServer");
//Create and Register Channel
TcpChannel serverChannel = new TcpChannel(9090);
ChannelServices.RegisterChannel(serverChannel, false);
//Expose Remote Object
RemotingConfiguration.RegisterWellKnownServiceType(typeof(HelloServer),
"HelloServer", WellKnownObjectMode.Singleton);
//Hang a Read
Console.WriteLine("Hit any key to exit!");
Console.Read();
}
}
public class HelloServer : MarshalByRefObject
{
public void SendObj(HelloClient hc)
{
hc.ReceiveString("This String from HelloServer");
}
public void SendString(string myString)
{
Console.WriteLine(myString);
}
}
}