Click here to Skip to main content
15,879,326 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi folks,

I've being starting out on WCF, I made a service and uploaded to my shared hosting.(after a bit of fiddling with configs, switching off security) I then navigate to the service.svc and it shows the metadata page. I run svcutil [address] and get a proxy class which I can consume through my console program. It all works fine I can add two numbers together!

However...
I try it in Silverlight this time adding a service reference, now when I instatiate the reference I get a KeyNotFoundException. What are the differences I need to be aware of when use a WCF service from silverlight?
Posted

1 solution

Hi Colin,

This problem was driving me mad on Friday so I thought I would let you know the answer :)

What you need to do is open the ServiceReferences.ClientConfig file in your Silverlight application that contains the client Service Reference. When I did this, I noticed it only contained an empty tag <configuration />.

What I then did was open the Web.config file in my host web application project (that contains the Web Service to be consumed). Locate the <endpoint> entry at the bottom for the service you are trying to expose to the Silverlight app. Change the binding attribute to "basicHttpBinding". Save the file.

Switch back to the ServiceReferences.ClientConfig file we opened earlier, in Solution Explorer, under Service References folder right click the service reference and select "Update Service Refeernce". You will notice that the config file is now populated correctly and you should be able to use the service now.

The default binding appears to be wsHttpBinding which for some reason does not generate any code in the ServiceReferences.ClientConfig file.

See if that works   [D'Oh]

Peter
 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900