tags:

views:

355

answers:

3

Given that my client code knows everything it needs to about the remoting object, what's the simplest way to connect to it?

This is what I'm doing at the moment:

ChannelServices.RegisterChannel(new HttpChannel(), false);

RemotingConfiguration.RegisterWellKnownServiceType(
    typeof(IRemoteServer), "RemoteServer.rem", WellKnownObjectMode.Singleton);

MyServerObject = (IRemoteServer)Activator.GetObject(
    typeof(IRemoteServer),
    String.Format("tcp://{0}:{1}/RemoteServer.rem", server, port));
A: 

WCF.

I have used IPC before there was a WCF, and believe me, IPC is a bear. And it isn't documented fully/correctly.

What’s the simplest way to connect to a .NET remote server object? WCF.

Will
+1  A: 

The first two lines are in the server-side code, for marshaling out the server object, yes?

In that case, yes, the third line is the simplest you can get at client-side.

In addition, you can serve out additional server-side objects from the MyServerObject instance, if you include public accessors for them in IRemoteServer interface, so, accessing those objects become the simple matter of method calls or property accesses on your main server object, so you don't have to use activator for every single thing:

//obtain another marshalbyref object of the type ISessionManager:
ISessionManager = MyServerObject.GetSessionManager();
Ishmaeel
A: 

@Ishmaeel: Do you mean that the only thing you need is the Activator.GetObject() call?

Answering my own question: Yes.

nickd