Silverlight Add Service Reference, Reference.cs Empty
It’s a bit tricky to add Service Reference on Silverlight. Since silverlight only support 2 methods like basic httpbinding and the other one.
So It’s different on how to do it.
You’ll Encounter why It’s always Failed and Empty on Reference.cs is you add From the Project –> add service reference.
In order to work Around this.
- Make sure on Your Web Service application has at least 1 Binding, Either BasicHttpBinding or the other one.Remember that If we add SVC, it won’t directly run as old asmx. so there has to be endpoint on the web.config
- On your BasicHttpBinding and Mex endpoint make sure the Contract is referring to your Interface
- Generate Proxy Always Using SLSvcUtil.exe it is design special for silverlight ,so if you use svcutil it will result differently.Output the file Somewhere, lets say called it :myreference.cs. it will output myreference.cs and the client.config
- Add Myreference.cs and client.config to you Silverlight Project, change the Namespace Correctly
- Delete the reference.cs on ServiceReference->yourServicereference
- If you have multiple Configuration for 1 service, you have to input the configuration Name From the config
Ex: MyServiceclient=new MyServiclient(“The Name”);
SLSvcUtil is shipped with SIlverlight 3,
so it’s on programfiles\microsoft SDKs\silverlight\3.0\Tools\
Test your service using wcftestclient to see if it's running or not
Cheers..