Tuesday, January 29, 2013

Silverlight with RIA WCF project can't add regular WCF service reference

Silverlight with RIA WCF project can't add regular WCF service reference

I don't know if this is a bug/feature but I need to find a way to make it work.

To recreate, use VS2012, open a new SL5 project with RIA services enabled. Create another project, add a simple WCF service (or a SL enabled WCF) and add a method that accepts or returns a simple object (I have an object with one string property in it). Try and add this as a service reference to your SL project. You'll receive this error, among others, in the warnings:

Custom tool warning: No endpoints compatible with Silverlight 5 were found. The generated client class will not be usable unless endpoint information is provided via the constructor.

and no generated code is actually generated.

I found that if I remove the object from the service method and use a simple string/int/bool instead, the reference is added just fine. Also, if I add the same service to a regular SL app without RIA, everything works like you would expect it to. Once I enable RIA on this app where the service is working, and update the service reference, the generated code is gone again.

I remember this used to work because I had projects that used both RIA and external WCF services. Is this a new VS2012 thing? Is there a way to solve this issue?

Thanks,

Eyal

Answers & Comments...

Answer: 1

I can duplicate the problem, and it only seems to happen if the Silverlight client has the 2 System.ServiceModel.DomainServices.Client and System.ServiceModel.DomainServices.Client.Web assemblies in its referenced assemblies. And only if it targets SL 5.

I have found 2 workarounds I recommend you try if your situation permits:

1) Change the Silverlight application to target Silverlight 4, not 5, or 2) Right-click the Service Reference and ask to Configure it. Click the checkbox to "Reuse types in specified referenced assemblies" and select all assembles except the 2 mentioned above.

This does appear to be a bug related to either SL 5 or VS2012. I will repost if I find a more satisfactory answer.

by : Ron Cainhttp://stackoverflow.com/users/1819246

Answer: 2

I have exactly the same problem, but the workarounds don't work...any other suggestion?

by : Georgeshttp://stackoverflow.com/users/1540107

Answer: 3

The problem is because of silverlight 5 and vs 2012 has some bug. [It can solve itself by restarting the vs2012]

If you look at your ServiceRefrences.ClientConfig will see it is empty. You need to enter your service refrences manually here. I have attached an example of my config page, you need to change the names accordingly

<configuration> <system.serviceModel>     <bindings>         <basicHttpBinding>             <binding name="BasicHttpBinding_IService2" maxBufferSize="2147483647"                 maxReceivedMessageSize="2147483647">                 <security mode="None" />             </binding>         </basicHttpBinding>     </bindings>     <client>         <endpoint address="../Service2.svc" binding="basicHttpBinding"             bindingConfiguration="BasicHttpBinding_IService2" contract="ServiceReference1.IService2"             name="BasicHttpBinding_IService2" />     </client> </system.serviceModel> 

by : user2020571http://stackoverflow.com/users/2020571




No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog