Everyone, I'm stumped by what I can only assume is trivial for someone with
experience with C# and the Remoting functionality. I'd like to host the
code for a particular class on a server:
namespace Space
{
public interface IShip
{
void launch();
void land();
}
}
namespace Space
{
public class Ship : IShip, MarshalByRefObj
{
Ship(string shipname) {...}
public void launch() {}
public void land() {}
}
}
Notice I'm being clear to present a one-argument constructor. I'm being a
purist and deciding that the construction of a Ship object should absolutely
require that the shipname be specified. Stated more clearly, I don't want
to include a zero-arg constructor just to make the remoting business simpler
(unless absolutely necessary).
I configure a server app to listen to port 5001 using TCP. I'm currently
using a config file, and would prefer to if at all possible.
I'm stumped as to how to instantiate a remote instance from a separate
client. I've gone through all the sample code, and none of them seem to
offer clear advice on how to effectively client-construct a Ship object
using Activator.GetObject (which seems to be what I'd want if the Ship were
server-activated) or even Activator.CreateInstance (which looks to me to be
the one I'm interested in). I see all nine overloaded version of
CreateInstance, and I even recognize those that allow you to pass in
arguments and whatnot, but I've no clear picture as to how to construct a
Ship using code on the server (via tcp, 5001).
Any good references? I've scrubbed MSDN and the examples are so simple that
they don't treat what I assume are the nuances of remoting.
Thanks for your help,
Jerry
je***@cs.stanford.edu