1

我正在使用 Silverlight 4,但遇到以下问题: 首先,代码:

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);

bitmapImage 触发带有“age network exception”的 ImageFailed 事件。无论我做什么,我似乎都无法加载任何外部图像。我需要配置什么特别的东西,或者为什么它不起作用?谢谢

4

2 回答 2

0

托管镜像的服务器需要有一个crossdomain.xml文件,允许跨域请求。该文件应大致如下所示:

<?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>

这使它敞开。

于 2010-07-28T16:40:04.987 回答
0

好的,我能够找到解决方法。我没有尝试让 SL 客户端从我的 ASP.NET 应用程序所在的服务器下载图像,而是使用 WCF 服务将数据直接流式传输到 SL 客户端,在那里我可以将它们重建为 BitmapImage 类型没有任何麻烦

于 2010-07-28T19:59:10.783 回答