Thursday, September 13, 2012

Crossdomain problems with Silverlight

Crossdomain problems with Silverlight

I have a real problem with Silverlight 4 and the 'to-ports' attribute in a crossdomain.xml policy file on facebook. 

Facebook in its wisdom has added the attribute to this crossdomain file on the server used to serve up its images. ie http://a8.sphotos.ak.fbcdn.net/crossdomain.xml.  This causes a real problem for Silverlight.  I thought it should at least just ignore the attribute but it doesn't.  I spent some time testing, and its presence seems to mean that Silverlight then ignores the file completely. Surely this must be a bug since the crossdomain file clearly indicates that it allows any sort of access.  Just not by Silverlight.

The reason I need it is that the facebook silverlight application I am working on needs to download the images and manipulate them.  I have no problems with showing the images in an image control, but of course trying to get at the pixel data causes a security exception. Does anyone have any suggestion on how to get around this, other than going back to the server and massively increasing its load.  And of course being Facebook, I have no control over the crossdomain file and I have about as much chance of getting them to modify the file as I have of refloating the Titanic.

I am using Silverlight 4 at the moment but I understand Silverlight 5 still has not addressed the problem.

Any suggestions.

Cheers

Andrew

Answers & Comments...

Answer: 1

Hi.

Did you find any solution till now?

I'm getting a 403 status when trying to access the clientaccesspolicy.xml file from http://a8.sphotos.ak.fbcdn.net/clientaccesspolicy.xml (I guess Silverlight first checks for this file, then for crossdomain.xml file).

Thanks.



Answer: 2

Hi,

Not sure if you would consider it a solution but I did get around it.  I include a small (tiny) flash program (1 pixel square, of background colour, since it needs to be visible to work) also embedded in the web page.  I also have a small script in the page. To load the images I call the script which in turn calls the Flash program which then downloads the image from Facebook (works since the crossdomain is a flash file after all). Passing the stream back was a problem so the flash converts it to a base64 string which is passed back to Silverlight via the script where it is converted back to a stream.

Voila and it works. Just rather slow.

Cheers

Andrew



Answer: 3

I got that same workaround to mostly work. I submitted feedback regarding the issue. If you are having the issue, please click through and vote for it:

https://connect.microsoft.com/VisualStudio/feedback/details/762430/silverlight-cant-handle-to-ports-in-crossdomain-xml





No comments:

Post a Comment

Send us your comment related to the topic mentioned on the blog