all groups > dotnet remoting > june 2005 >
You're in the

dotnet remoting

group:

Attaching to multiple servers with one application


Attaching to multiple servers with one application Roy Chastain
6/29/2005 3:21:14 PM
dotnet remoting:
I have a service that provides a singleton SAO. I can be running this service on more than one system at a time.
I have an application that attempts to use the singleton via remoting. The idea was that this application could connect to more
than one instance (machine) of the service at one time. The code below was my attempt. Each time the code is called the
'server_name' parameter to the UriBuilder is different.

uri_builder = new UriBuilder("TCP",server_name,remote_port,"HGSMonitoring/RemotingManager.rem");
client_type_entry = new WellKnownClientTypeEntry(typeof(RemotingManagerBase),uri_builder.Uri.AbsoluteUri);
RemotingConfiguration.RegisterWellKnownClientType(client_type_entry);

Unfortunately this does not work.
The RegisterWellKnownClientType call throws the following exception.
Attempt to redirect activation of type 'KMS.Core.Remoting.Shared.RemotingManagerBase, RemotingSharedBase' which is already
redirected.

In retrospect this makes some sense, but since it is activated using the URI, i still think that it should work.

Anyway, the bottom line is.

Is there any REASONABLE way to allow one application to use remoting to use the same SAO Singleton on different machines (or
actually URIs in this case) at the same time?



-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
Re: Attaching to multiple servers with one application Cordell Lawrence
6/29/2005 7:03:59 PM
Hey Roy,
Try using the Activator.GetObject( Type type, string url ) to remote SOA
objects that are running on specific machines.

so ...

// Untested verified code

{
....
remoteServerUri1 = new UriBuilder( ... );
remoteServerUri2 = new UriBuilder( ... );

// Use / get (a proxy to) an object running on Server1
MyRemoteObject objOnServer1
= (MyRemoteObject)Activator.GetObject( typeof ( MyRemoteObject ),
remoteServerUri1.Uri.AbsoluteUri);

// Use / get (a proxy to) an object running on Server2
MyRemoteObject objOnServer2
= (MyRemoteObject)Activator.GetObject( typeof ( MyRemoteObject ),
remoteServerUri2.Uri.AbsoluteUri);

....
}

Hope this helps
Cordell Lawrence
Teleios Systems Ltd.

[quoted text, click to view]
UriBuilder("TCP",server_name,remote_port,"HGSMonitoring/RemotingManager.rem"
);
[quoted text, click to view]
WellKnownClientTypeEntry(typeof(RemotingManagerBase),uri_builder.Uri.Absolut
eUri);
[quoted text, click to view]
'KMS.Core.Remoting.Shared.RemotingManagerBase, RemotingSharedBase' which is
already
[quoted text, click to view]

Re: Attaching to multiple servers with one application Roy Chastain
6/30/2005 7:39:09 AM
I was already using Activator, but I figured out that you might be suggesting that I don't have to call
RegisterWellKnownClientType and upon more carefull reading, the doc says that RegisterWellKnownClientType is not needed if you use
Activator instead of new.

I removed the call to RegisterWellKnownClientType and all appears to works now.

Thanks

[quoted text, click to view]

-------------------------------------------
Roy Chastain
KMSYS Worldwide, Inc.
AddThis Social Bookmark Button