Using .NET Remoting with multiple users

  • Thread starter Thread starter Paul Steele
  • Start date Start date
P

Paul Steele

I am developing a client/server app and would like to use .NET Remoting to
allow the server to communicate with clients. I've been able to test this
with a single client, but .NET Remoting seems to make it very difficult to
establish connections with multiple users. This is the code I use for
connecting a single user:

IDictionary props = new Hashtable();
props["port"] = "0";
props["name"] = RemoteMachineName;
TcpChannel channel = new TcpChannel(props, null, null);
ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteObject),
"tcp://" + RemoteMachineName +
":9999/ExamProctor/RemoteObject");

This works fine and allows be to connect to the remote object as expected.
When I try to connect another user, the call to RegisterWellKnownClientType
fails indicating that the remote object has already been redirected. Is
there any way to use .NET Remoting to establish remote objects on multiple
clients?
 
There are two ways to set this up:

RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteObject),
"tcp://" + RemoteMachineName +
":9999/ExamProctor/RemoteObject", WellKnownObjectMode.SingleCall);

RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteObject),
"tcp://" + RemoteMachineName +
":9999/ExamProctor/RemoteObject", WellKnownObjectMode.Singleton);


By default, it is set to Singleton. This is not a bad thing, in some
instances, but is likely the source, or at least part of the source, of your
problem. Check out:

http://www.devx.com/dotnet/Article/6965/


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Cowboy (Gregory A. Beamer) - MVP said:
There are two ways to set this up:

RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteObject),
"tcp://" + RemoteMachineName +
":9999/ExamProctor/RemoteObject", WellKnownObjectMode.SingleCall);

RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteObject),
"tcp://" + RemoteMachineName +
":9999/ExamProctor/RemoteObject", WellKnownObjectMode.Singleton);

Do you mean "RegisterWellKnownServiceType"? No form of
"RegisterWellKNownClientType" take three arguments.
 
Back
Top