Exception when registering a familiar type of client
I am using .NET remoting for communication between client and server. I implemented a client application and caught an exception by registering an object on the client using "RegisterWellKnownClientType". An exception is "an attempt was made to redirect an activation of a type that is already redirected." I only get this exception when I register the object a second time. Here's some code that illustrates this:
IpcClientChannel clientChannel = new IpcClientChannel();
try
{
ChannelServices.RegisterChannel(clientChannel, true);
RemotingConfiguration.RegisterWellKnownClientType(typeof(RemoteTester), m_remoteUrl);
}
This code is implemented in mine ClientClass
. Initially, I create an object, say myClient
of ClientClass
, to access the methods exposed by that class. It also includes a method for registering an object on the client. When this object ( myClient
) is located, I create another instance ClientClass
and access the method that registers the object with the client. During this process, I am getting the above exception. The object registration method on the client is used to make remote calls to the server.
Let me know if I'm missing something here.
Thanks, Mustaq
source to share
IsWellKnownClientType (.., ..), this method does not return bool, it returns WellKnownClientTypeEntry
when checking if the specified System.Type object is registered as a well-known client type. if WellKnownClientTypeEntry is null then not registered.
Here is my code to solve the problem. hope it helps you ...
WellKnownClientTypeEntry entry = RemotingConfiguration.IsWellKnownClientType (typeof (RemoteConverter));
if (entry == null) {RemotingConfiguration.RegisterWellKnownClientType (typeof (RemoteConverter), "http: // localhost: 4000 / ServiceURI"); }
RemoteConverter remoteConverter = new RemoteConverter ();
now call remorte Methods remoteConverter.RemoteMethod (.......)
thank.
source to share