Exception: Attempt to redirect activation of type

Hi

In my remoting client application i am using following code to register the configuration file.My configuration file contains the URI of the remote object .

String filename = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;

RemotingConfiguration.Configure(filename, false);

When i am executing this code inside a method first time it is working fine but second time it is giving

Attempt to redirect activation of type      exception .

Any work around for that

Thanks,

Arabinda

 




Answer this question

Exception: Attempt to redirect activation of type

  • Drunkalot

    Make sure you configure the Client only once. I would probably do it this way.....

    using System;
    using RemotingServer;

    namespace MyRemotingApp
    {
      public class RemotingClient
      {
        public static RemotingServer.IRemoteServer obj =null;
        public RemotingClient()
          {
            if (obj == null) //To Ensure this executes only once.
            {
               RemotingConfiguration.Configure("ClientConfiguration.exe.config");
               obj = (RemotingServer.IRemoteServer)
               MyRemotingApp.RemotingHelper.CreateProxy(typeof(RemotingServer.IRemoteServer));
            } 
            if (obj == null) System.Console.WriteLine("Could not locate server");
          }
       }
    }

     

    If you need to change the ServerURI on the fly, you can pass the URI to the RemotingClient Class.

    PS: This example uses RemotingHelper class which you can refer from ingo rammer's Advanced .NET Remoting.



  • iffishah

    You do need to reconfigure your client application.
    For examle you can put the "RemotingConfiguration.Configure(filename, false);" code in your main Program.cs class to ensure that it is executing only once.



  • Exception: Attempt to redirect activation of type