tags:

views:

218

answers:

2

Hi,

I am using .NET remoting to communicate between the client and server. I implemented the client application and encountered an exception while registering an object on the client using "RegisterWellKnownClientType". The exception is "attempt to redirect activation of type which is already redirected". I get this exception only when I register the object for the second time. Here is the code that illustrates it:

IpcClientChannel clientChannel = new IpcClientChannel();
try
   {
      ChannelServices.RegisterChannel(clientChannel, true);
      RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), m_remoteUrl);             
   }

This code is implemented in my "ClientClass". Initially i create an object say myClient of ClientClass to access the methods exposed by this class. This also includes the method to register the object on the client. Once this object (myClient) is disposed i create another instance of the ClientClass and access the method which registers the object on the client. During this process i get the above mentioned exception. The method to register the object on the client is used in order to make remote calls to the server.

Let me know if I am missing anything here.

Thanks, Mustaq

A: 

Test if you have already registered the client type like so:

if (RemotingConfiguration.IsWellKnownClientType(typeof(RemoteTester)) == false) {
    // register
    RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), ...
}

-Oisin

x0n
I did what you specified with some modifications (IsWellKnownClientType will not return bool so did the appropriate check) and i got rid of the "attempt to redirect" exception. Now when i use the remote proxy object and call any method exposed by the server i get an exception mentioning "Failed to connect to an IPC port. System could not find the file specified." Note that this happens only when the second instance of my CilentClass access the remote object.
MUSTAQ