views:

85

answers:

2

Hi, I'm using Silverlight 4 and I'm experiencing the following problem: First off, the code:

BitmapImage bitmapImage = new BitmapImage();
        bitmapImage.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
        bitmapImage.DownloadProgress += new EventHandler<DownloadProgressEventArgs>(bitmapImage_DownloadProgress);
        bitmapImage.UriSource = new Uri("http://choteborsky.aspone.cz/Images/Label.png", UriKind.Absolute);
        bitmapImage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(bitmapImage_ImageFailed);

The bitmapImage fires the ImageFailed event with the "ag e network exception". I seem to be unable to load any external images, no matter what I do. Is there something special I need to configure or why is it not working? Thanks

A: 

The server where the image is hosted needs to have a crossdomain.xml file, allowing cross-domain requests. The file should, roughly, look like:

<?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 include-subpaths="true" path="/" />
      </grant-to>
    </policy>
  </cross-domain-access>
</access-policy>

That makes it wide open.

consultutah
I have the clientaccesspolicy.xml which looks exactly like this. One more thing is, I found this sample online http://www.shinedraw.com/data-handling/flash-vs-silverlight-loading-external-image/ and the SL image viewer works just fine on that very image. And there is nothing significanly different in the code.
Jan Kratochvil
A: 

Ok, I was able to find a workaround solution. Instead of trying to get the SL client to download the image from the server on which is sitting my ASP.NET app, I use a WCF service to stream the data directly to the SL client where I'm able to reconstruct them into BitmapImage type without any trouble

Jan Kratochvil