Creating a remoting poxy for interface with generic types

I've created a class that inherits from MarshalByRefObject. This class has methods that have generic types as arguments and return types. The remoting object is hosted by a windows service.

I'm aware that I can't use SOAP with generics, but the TCP channel appears to work. What I want to accomplish is to create a proxy class like the ones soapsuds.exe create. That way I will not have to put the entire server application on the client, only the proxy. But the soapsuds.exe tool doesn't appear to support generics - not event with the -types argument.

Is there a way around this, or will I have to put the full assembly on the client side

Thanks in advance.

- Johan


Answer this question

Creating a remoting poxy for interface with generic types

  • maruthi.vj.

    Johan, the best way to do this is to make a shared assembly with just the interface that you'll have the service implement. This way your service implementation doesn't have to live on the client, and your client proxy can be strongly typed.

    Cheers,

    JJustice [MSFT]


  • WorldChoice

    Thanks, that helped a lot.

    I've extracted the relevant methods from MySvc to IMySvc and put IMySvc in a separate assembly. I can then do this on the client:

    IMySvc = (IMySvc)Activator.GetObject(typeof(IMySvc), "tcp://localhost:1234/MySvc");

    But with .config files I can usually get rid of that syntax and simply write:
    MyRemotType obj = new MyRemoteType();

    But I obvously can't write
    IMySvc = new IMySvc();
    since IMySvc is an interface and not a type name.

    I'd prefer to keep the host name and port number in the .config file instead of in the code. And being able to use the shorter form gives much cleaner code.

    Any ideas on how I can do that

  • Joe A

    Johan, there's actually a great article on just this problem up on Ingo Rammer's Remoting FAQ site [1]. While you're there, you might want to check out some more of the articles Ingo's posted -- he's written some great articles.

    Cheers,

    JJustice [MSFT]

    [1] http://www.thinktecture.com/Resources/RemotingFAQ/USEINTERFACESWITHCONFIGFILES.html


  • Creating a remoting poxy for interface with generic types