Skip to main content
Home Forums Silverlight Programming Programming with .NET - General Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS Feed
4 replies. Latest Post by cjjubb99 on July 7, 2009.
(0)
cjjubb99
Member
15 points
35 Posts
07-03-2009 4:59 AM |
Hi all.
I am having trouble catching an image related error within Silverlight.
I am currently using an RSS feed for news. Each news story (item) contains a thumbnail (itemthumbnail).
The majority of these images are displayed correctly.
However, a small number of these images are not displayed correctly and I encounter the following error
Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR
I have noticed that I sometimes get this error even if the source of the images is valid.
I parse the RSS using LINQ (see the code below)
Dim rssItems = From rssItem In xmlStories.Descendants("item") _ Where rssItem.Element("title") IsNot Nothing Take 8 _ Select New MySilverlight.RSSItem With _ {.title = (CStr(rssItem.Element("title")).ToUpper).Trim() _ , .description = (Left(CStr((rssItem.Element("description"))).ToUpper, 150)) _ , .pubDate = (CDate(rssItem.Element("pubDate"))) _ , .category = (CStr(rssItem.Element("category"))).Trim() _ , .itemthumbnail = IIf(IsNothing(CStr(rssItem.Element("itemthumbnail"))), "../Images/noimage.png", IIf(Right(CStr((rssItem.Element("itemthumbnail"))), 3) = "gif", "../Images/noimage.png", (CStr(rssItem.Element("itemthumbnail")))).Trim()) _ }
The itemthumbnail data is always correctly passed to the RSSItem object. I have already excluded the images that are GIF format and those where itemthumbnail is empty,
Does anyone know what could be causing this error.
Is it possible to put a TRY CATCH within this line?
, .itemthumbnail = IIf(IsNothing(CStr(rssItem.Element("itemthumbnail"))), "../Images/noimage.png", IIf(Right(CStr((rssItem.Element("itemthumbnail"))), 3) = "gif", "../Images/noimage.png", (CStr(rssItem.Element("itemthumbnail")))).Trim()) _
Any help would be grately appreciated.
jay nana...
Contributor
3388 points
624 Posts
07-03-2009 5:22 AM |
what if the format is other than Gif?
07-03-2009 5:35 AM |
All the other images are .JPG format.
Amanda W...
All-Star
17241 points
1,466 Posts
07-07-2009 5:42 AM |
Hi,
The error code 4001 means the request source does not exist. So we would suggest that you can try to check if the path that you referenced the image is correct.
07-07-2009 12:14 PM |
I solved this error using code found here
http://sergeybarskiy.spaces.live.com/Blog/cns!2383900F69B808E0!178.entry