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]  | 
Tuesday, June 24, 2008 9:41:35 AM (Eastern Standard Time, UTC-05:00)
Thanks for this post. It probably saved me several hours of debugging this morning.

I have a bunch of WCF services and I am upgrading the Silverlight client from Beta 1 to Beta 2 and I had the same problem. I changed my policy file per your post and it fixed the problem.
John Hauppa
Wednesday, July 02, 2008 12:41:46 PM (Eastern Standard Time, UTC-05:00)
Thanks A Lot for the post. It fixed my problem, which I was dealing with, for the past two days.
Reny Mathew
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):

Live Comment Preview