David Brown
David Brown

Reputation: 36239

AG_E_NETWORK_ERROR when loading a remote Image in SIlverlight

I have a ListBox that gets populated with items read from a JSON response. Each item has an Image control that displays the thumbnail at the remote URL given by the Thumbnail property. I created a custom IValueConverter to convert the URL to a BitmapImage, but the image still didn't display. So I finally realized that I could capture loading errors with the ImageFailed event.

What I get is an AG_E_NETWORK_ERROR. I looked at Silverlight's URL Access Restrictions and the table states that loading an Image from another domain is allowed without a crossdomain.xml file.

I'm positive that the URL is valid and points to an image, because I can copy and paste it directly from the JSON and view it in a browser. Yet, Silverlight refuses to load it.

Why is this?

EDIT: I installed Fiddler, which does show requests being made when the Silverlight page is loaded. None of these requests are for the image, however. It appears that Silverlight isn't even attempting to make a request and automatically throwing the exception.

Upvotes: 1

Views: 3022

Answers (3)

JoanComasFdz
JoanComasFdz

Reputation: 3066

Another way:

  1. Add de Web project in order to have your own development server.
  2. Set it as startup project.
  3. Open its properties. Web tab: mark specific page.
  4. Web tab / Debuggers (at the bottom): mark Silverlight.

Now you can run & debug your Silverlight application without installing an ISS Server.

Upvotes: 0

David Brown
David Brown

Reputation: 36239

Someone answered this on the Silverlight forums. The problem turned out to be that I was using the auto-generated debug page, instead of an IIS website. Silverlight doesn't allow cross-protocol calls (in this case, from file:// to http://).

Upvotes: 5

Jeff Wilcox
Jeff Wilcox

Reputation: 6385

Are you actually trying to download the image (binary content) using WebClient or another HTTP stack in Silverlight? Unless you can write that cross domain file, this is not possible.

I believe you must just set the URL of the Image.Source, which then would let Silverlight resolve the image. You would also see Fiddler make the request at that time.

Upvotes: 1

Related Questions