tags:

views:

661

answers:

3

Is there a way to create WCF proxy objects on the fly without using codedom? By on the fly I mean during runtime. So lets say I have a smart client application that is accessing a WCF service. The Data Contract for the WCF service is changed while the client is running. I want to dynamically create a new proxy object that reflects the changed data contract.

A: 

I came up with a solution, using a shared assembly for contracts and endpoint interfaces.

So The Projects Would Be

  1. Host
  2. Contacts & Endpoints
  3. Client With Proxy

    public class YourProxy : ClientBase {}

Elijah Glover
+3  A: 

You should read this article: WCF the Manual Way… the Right Way

And look into using the ChannelFactory class. You are going to have alot of reflection to create and invoke the members if the contract changes on the fly but I can't think of any reason you shouldn't be able to do it.

Mike Glenn
A: 

Be careful about doing too much stuff on the fly. Even using reflection it might become too easy to couple your Client/Proxy/Service/Contract together too much.

Creating manual proxies and adding them as a reference to your client is a fantastic idea.

Terry Donaghe