I have a Silverlight application which uses WCF for its communications with the server. Both Silverlight and WCF are running on the local machine (localhost). When the Silverlight makes a call to the service it fails with aa communication exception. I understand that this is because I don't have a clientaccesspolicy file, but since the WCF endpoint is running on http://localhost:port I defined an interface, IPolicyRetriver, and added an implementation to the service which is returning the clientaccesspolicy in a stream.
My question is, what do I have to configure so that it will run without a problem? I understand that I have to change or add something to my ServiceReference.ClientConfig file, but I don't understand what. I've included my ServiceReference.ClientConfig below. Please let me know what to change or add to it, and where in Silverlight to add this code. Please do not paste any links here to help me as I have opened every link I could during the last two days - but still don't understand.
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IMapService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="../MapService.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IMapService" contract="MapService.IMapService"
name="BasicHttpBinding_IMapService" />
</client>
</system.serviceModel>
HELP ME PLEASE!
You shouldn't need to change anything with your service configuration or code. Place the clientaccesspolicy.xml in the ROOT of the service website. If you are using Visual Studio, you may need to make a property change to get this to work. Silverlight will look for the existence of the file. I might help you to use a tool like Fiddler to see where Silverlight is looking for the file.
There is one link that I found very helpful but since you don't want any links, I won't provide it.