我有奇怪的错误,在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检索图像后,我有奇怪的错误:

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

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

例外:

ErrorException = {System.Exception: AG_E_NETWORK_ERROR}

当浏览器刷新时 其他 图像负载失败(图像列表相同!)。我在汇编(XAP)中配置的图像的同一列表总是正常工作。

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

有帮助吗?

解决方案

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

UriKind.RelativeOrAbsolute

其他提示

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

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top