title: Returning an interface from a WCF service
body: <p>I have some .NET remoting code where a factory method, implemented in some server side class, returns interfaces to concrete objects, also executing on the very same server. .NET remoting automagically creates proxies and allows me to pass the interfaces across to the client, which can then call them directly.</p>
  
  <p>Example interfaces:</p>
  
  <pre><code>public interface IFactory
  {
      IFoo GetFoo();
  }
  
  public interface IFoo
  {
      void DoSomething();
  }
  </code></pre>
  
  <p>Example client code:</p>
  
  <pre><code>...
  IFactory factory = (IFactory) System.Activator.GetObject (typeof (IFactory), url);
  ...
  IFoo foo = factory.GetFoo ();  // the server returns an interface; we get a proxy to it
  foo.DoSomething ();
  ...
  </code></pre>
  
  <p>This all works great. However, now I am trying to migrate my code to WCF. I wonder if there is a means to pass around interfaces and having WCF generate the proxies on the fly on the client, as does the original .NET remoting.</p>
  
  <p>And I don't want to return class instances, since I don't want to expose real classes. And serializing the full instance and sending it back and forth between the server and the client is not an option either. I really just want the client to talk to the server object through an interface pointer/proxy.</p>
  
  <p>Any ideas?</p>