Skip to main content

Microsoft Silverlight

Answered Question Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS FeedRSS Feed

(0)

cjjubb99
cjjubb99

Member

Member

15 points

35 Posts

Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS Feed

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 nanavati
jay nana...

Contributor

Contributor

3388 points

624 Posts

Re: Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS Feed

what if the format is other than Gif?

Jay K Nanavaty
www.technologyopinion.com
Mark as answer if it helps. It will also help others...

cjjubb99
cjjubb99

Member

Member

15 points

35 Posts

Re: Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS Feed

All the other images are .JPG format.

Amanda Wang - MSFT
Amanda W...

All-Star

All-Star

17241 points

1,466 Posts

Re: Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS Feed

 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. 

Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.

cjjubb99
cjjubb99

Member

Member

15 points

35 Posts

Answered Question

Re: Sys.InvalidOperationExcepetion: Image error #4001 in control 'Silverlight': AG_E_NETWORK_ERROR - RSS Feed

I solved this error using code found here

http://sergeybarskiy.spaces.live.com/Blog/cns!2383900F69B808E0!178.entry

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities