在Windows应用商店中加载图像时出现ag_e_network_error

时间:2013-04-06 22:56:58

标签: .net windows-8 windows-runtime windows-store-apps

我遇到了一些问题,这应该是一个非常简单的任务,从URL加载Windows商店应用中的图像。我的代码如下:

  Image image = new Image();
  image.Stretch = Stretch.None;
  image.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left;
  BitmapImage bitmap = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
  image.Source = bitmap;
  bitmap.ImageFailed += bitmap_ImageFailed;
  panel.Children.Add(image);
  scroller.ScrollToVerticalOffset(Double.MaxValue);

只有在我加载图像时,我才会得到一个带有错误AG_E_NETWORK_ERROR的ImageFailed事件,原因并非明显。该映像存储在Azure Blob存储中,可通过URL访问。我知道这很好用。

我需要的图像的网址是通过ASP.NET Web API角色的Web请求发送的。

当我第一次向本地托管的Web api实例(localhost)发出本地Web请求时,问题似乎是间歇性地发生的,该实例为我提供了图像URL,然后通过azure blob存储中的给定URL获取图像。 / p>

它似乎没有遵循任何明显的模式,让我相当困惑。

1 个答案:

答案 0 :(得分:1)

您是否阅读过thisthis

我怀疑您正在使用带有网址的BitmapImage,这可能会导致问题。尝试使用HttpClient,让我知道它是否有效?

相关问题