views:

92

answers:

2

I have strange bug with showing image in silverlight. The problem to show list of images that configured in xml file and this xml downloaded from server by WebClient type.

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

after xml downloaded and images retrieved from xml i have strange bug:

I add images to stackpanel dynamically. But images not always shown! Some times image load fails:

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

Exception:

ErrorException = {System.Exception: AG_E_NETWORK_ERROR}

When browser refreshed other image load fails(image list is the same!). The same list with images that i configure in assembly (xap) always working fine.

Its looks like problem with WebClient or something like that. What that can be???

A: 

Try setting the UriKind, that might help.

UriKind.RelativeOrAbsolute
Avatar
UriKind is set to RelativeOrAbsolute. Images loads, but sometimes...
Evgeny
+1  A: 

load it like this:
/[YOUR_PROJECT_ASSEMPLY_NAME];component/[Path_to_images]/[your_image]

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

Alexander Bykin
Images managable by customer and located not in assembly.
Evgeny
you edit your question, at first time you need to load from assembly and i give you answer.
Alexander Bykin
In the first question was talking about list of images and some images loads fails! After browser refresh other set of images load fails. So if same image loaded one time and after refresh load fails how it can be problem with this source configuration?
Evgeny