0

我在 Silverlight 中显示图像时遇到了奇怪的错误。显示在 xml 文件中配置的图像列表以及通过 WebClient 类型从服务器下载的该 xml 的问题。

WebClient client = new WebClient();
            client.AllowReadStreamBuffering = true;
            client.OpenReadAsync(new Uri(path, UriKind.Relative), new GalleryUserState() {Gallery=gallery, PathToXml = path });
            client.OpenReadCompleted += new OpenReadCompletedEventHandler(request_for_Gallery_Completed);

下载 xml 并从 xml 检索图像后,我有一个奇怪的错误:

我动态地将图像添加到堆栈面板。但图像并不总是显示!有时图像加载失败:

    curImage.ImageFailed += new EventHandler<ExceptionRoutedEventArgs>(curImage_ImageFailed);
 void curImage_ImageFailed(object sender, ExceptionRoutedEventArgs e)
   {
   }

例外:

ErrorException = {System.Exception: AG_E_NETWORK_ERROR}

当浏览器刷新其他图像加载失败(图像列表相同!)。与我在程序集(xap)中配置的图像相同的列表总是可以正常工作。

它看起来像 WebClient 或类似的问题。那可以是什么???

4

2 回答 2

2

尝试设置 UriKind,这可能会有所帮助。

UriKind.RelativeOrAbsolute
于 2010-09-16T18:12:48.433 回答
2

像这样加载它:
/[YOUR_PROJECT_ASSEMPLY_NAME];component/[Path_to_images]/[your_image]

样本:
/System.Windows.Controls.Data.RIADataFilter.Control;component/Images/Plus.png

于 2010-09-18T08:41:30.020 回答