I’m updating my existing applications to Silverlight 2 RC and bumped once again into the not so self-explanatory “AG_E_NETWORK_ERROR“. Due to developer’s-momentary-amnesia caused by ultra-multi-tasking , I just couldn’t find a reason for the error and spent unnecessary time to solve something I had already done once or twice. So I decided to note down an online tip to check out for future Silverlight experiments before diving into detailed forum searches.
If your Silverlight application is using media files from your local application directory, you need to copy it to the ClientBin directory. In case you forget to do so, you will see an Error Dialog in your browser once you run the application with this joyful message:
Error: Unhandled Error in Silverlight 2 Application SilverlightApp.xap
Code: 4001
Category: MediaError
Message: AG_E_NETWORK_ERROR
This was the error in my application and taking a closer look at the ClientBin solved my problem. In fact, your error could be caused by something else. If you need some time to find more about your error, but you don’t want your application to shoot out this error dialog, add the MediaFailed event to your MediaElement objects and handle errors as appropriate. This is a clue I got from Mike Snow’s “Silverlight Tips of the Day” blog; which has always lots of up-to-date info!
Here’s some lyrical closing statement to end my entry plus today:
May your night
be bright
as Silverlight.
What if it’s not amnesia; but a split personality issue?!? LOL. Upon further investigating this issue – actually it’s quite obvious that the poet didn’t/couldn’t/won’t remember the developer’s error correction. Ok – no need to panic then; calm down; everything is resolved! Is it?!? 🙂
[…] Crocus Girl gives us a Silverlight Tip [AG_E_NETWORK_ERROR] […]
Thanks! That is what I needed! I added a carousel control and had the file mapped incorrectly.
Thanks !!!
I should not say I wasted too much time on it , but once I read it here … It solved my problem … I wud have never been able to fix it myself…
Many Thanks
varun
I wonder why after a build it doesn’t move the media over automatically. O well. Thanks for this tip. It definately helped.
Thanks alot….
I’m happy the info was helpful!
OK this didn’t work for me because I’m not accessing local media, but I did want to mention that people should research the clientaccesspolicy.xml in the root that specifies credentials for silverlight to access files…
also crocus girl is fairly cute
I was facing an issue while binding Image URL to an Image in Silverlight app. I solved it by publishing the application to IIS instead of running it from the file system . Refer to my blog for more details http://nileshgule.blogspot.com/2011/06/ngtweet-part-5-big-bang-refactoring.html