tags:

views:

150

answers:

2

In CAO there is no URI, so specified type has to be registered on the server side. But if my client and server interact through the same interface (remote object implements interface) then how can I call CAO remote object from client side. It gives me exception if I try to call Acitvator.CreateInstance using interface type. for e.g.

RemoteObject.IRemoteObject obj = (RemoteObject.IRemoteObject )Activator.CreateInstance(typeof(RemoteObject.IRemoteObject), null, url);

above code throws exception.

A: 

I'm not sure I can post a solution to your actual issue. However, I can explain why the code you've posted throws an exception. You are trying to create an instance of an interface type. This cannot be done, an interface contains no implementation. Generically speaking, I believe what you want to do is create the remote object type and the cast it to the interface that you want to be using (assuming the object implements the interface).

Timothy Carter
A: 

You might want to consider using the technique outlined in this MSDN article Implementing Broker with .NET Remoting Using Client-Activated Objects. This pattern uses a SAO factory to create CAOs.

I've used this technique on the job and it works well.

Nathan