Making the Silverlight-Enabled WCF Service in Dev10 Beta 1 Work with Silverlight 2

In Dev10 Beta 1, the Silverlight-enabled WCF Service template is the version used for Silverlight 3 beta.  This uses a custom binding to enable binary encoding, and is incompatible with Silverlight 2 applications.  If you attempt to add a reference to it, you’ll see errors like the following:

wcf_warnings

(note that you might also see this error if you are using Silverlight 3 beta and have the Silverlight 2 SDK installed)

To make it work with Silverlight 2, however, you can just tweak to the web.config where the service is hosted to use basicHttpBinding without the custom bindingConfiguration.  In the web.config file, under the <system.serviceModel> node change the configuration from something like:

 <services>
     <service behaviorConfiguration="UseSilverlightWcfTemplate.Web.Service1Behavior"
         name="UseSilverlightWcfTemplate.Web.Service1">
         <endpoint address="" binding="customBinding" bindingConfiguration="UseSilverlightWcfTemplate.Web.Service1.customBinding0"
             contract="UseSilverlightWcfTemplate.Web.Service1" />
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
     </service>
 </services>

to:

 <services>
     <service behaviorConfiguration="UseSilverlightWcfTemplate.Web.Service1Behavior"
         name="UseSilverlightWcfTemplate.Web.Service1">
         <endpoint address="" binding="basicHttpBinding" contract="UseSilverlightWcfTemplate.Web.Service1" />
         <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
     </service>
 </services>

Then rebuild the web project and update your service reference.