Thursday, June 12, 2008

In moving a Silverlight 2.0 app to use Beta2, I hit a wall when trying to access my WCF Service which was working perfectly fine in Beta1.

I was getting a 404 telling me that the service could not be found. While the exception itself told me nothing more than that a 404 had been returned (with no inner exception), thankfully the exception popup window had the critical info in the header: TargetInvocationException crossed a native/managed boundary. So I knew that the cross domain problem had returned with the new bits. It wasn't until I searched for "TargetInvocationException" and found this thread did I see exactly what was causing the problem and how to fix it.

It turns out that if you are using the ClientAccessPolicy.xml file in the service to overcome cross domain issues, the file needs to be modified from what was needed in Beta1. Here's the new version. What has changed is that I am now using the "http-request-headers" attribute in the allow-from element. I'm not sure why it worked without this in Beta1, but this works now, so I'm a happy camper.

<?xml version="1.0" encoding="utf-8"?>
<access-policy>
    <cross-domain-access>
        <policy>
            <allow-from http-request-headers="*">
                <domain uri="*"/>

            </allow-from>
            <grant-to>
                <resource path="/" include-subpaths="true"/>
            </grant-to>
        </policy>
    </cross-domain-access>
</access-policy>

Thursday, June 12, 2008 8:09:30 AM (Eastern Standard Time, UTC-05:00)  #     |  Comments [2]  |