views:

408

answers:

2

I"m trying to connect my Silverlight application to a WCF service that I'm hosting myself. I've created a clientaccesspolicy.xml file, and placed it in the service host project's root, but when I try to hit the service, my http sniffer says it can't be found. Specifically the file it's looking for is http://localhost:8080/clientaccesspolicy.xml.

I'm running the server and the silverlight app in debug mode in Visual Studio 2010. Do I need to put the file somewhere else?

+2  A: 

The clientaccesspolicy.xml file must be in the root of the domain where the service is hosted. You may already have it there but the virtual path of the web site or web application from the property page will need to be changed to "/"

See this page for more information.

DaveB
+2  A: 

I did not understand how you're hosting your WCF service?

Is it hosted in a asp.net application or a windows host (self-hosting)? If the latter is the case, you may have to implement a clientaccesspolicy service that provides the content of the clientaccesspolicy.xml file on request.

For example like this.

Jon Andersen
Thanks! Following that article, as well as this one: http://tinyurl.com/ybphlhq, to set up the host to programmatically include the policy worked perfectly.
Mike Pateras
The code at Carlos' blog does the trick. Be warned though: it feels like using magic rather than using a library. I hope I'll get used to it.
Dimitri C.