title: Sharing service interfaces and model in Silverlight, using WCF
body: <p>Say I have the following interface that I want to share between my server (a regular web service) and my client (a silverlight 2.0 application):</p>
  
  <pre><code>public interface ICustomerService
  {
      Customer GetCustomer(string name);
  }
  </code></pre>
  
  <p>My web service implements this interface, and references a class library where <code>Customer</code> type is defined.</p>
  
  <p>Usually, if you want to consume this service from a WCF client, say a winforms app, you could share your model assembly and your service contract interfaces. Then, by using a <code>ChannelFactory</code>, you can dynamically create a proxy which implements your service interface. Something like:</p>
  
  <pre><code>ICustomerService myService = new ChannelFactory&lt;ICustomerService&gt;(myBinding, myEndpoint);
  Customer customer = myService.GetCustomer("romain");
  </code></pre>
  
  <p>I basically want to do the same thing, but from a Silverlight 2.0 application. The silverlight <code>ChannelFactory</code> doesn't seems to act like the other one...</p>
  
  <p><strong>Do you know if it's possible ?</strong></p>
  
  <p>Note : Since a Silverlight application can only refers Silverlight projects, I have:</p>
  
  <p>Two versions of MyModel.dll which contains <code>Customer</code> type:</p>
  
  <ul>
  <li>One compiled targetting .NET framework 3.5, referenced by my web service project </li>
  <li>Another compiled targetting the silverlight 2.0 framework, referenced by my silverlight app</li>
  </ul>
  
  <p>Two versions of MyServicesContracts.dll which contains <code>ICustomerService</code> interface:</p>
  
  <ul>
  <li>One compiled targetting .NET framework 3.5, referenced by my web service project </li>
  <li>Another compiled targetting the silverlight 2.0 framework, referenced by my silverlight app</li>
  </ul>