Greetings
Problem
When i’m trying to add images to my silverlight project I get the error: "AG_E_NETWORK_ERROR".
Recreate
I create a new silverlight 4 project without a web part. So I only get MyApplication.
In MyApplication I add a map called “Images” and in that map I add a few images. Egg.png, Chicken.png.
Now I wish to load these images to my silverlight project. In the mainpage.xaml I place:
<Image Source="/Images/Egg.png" /> but this does’t load.
So I try it from code behind:
var imag = new BitmapImage(new Uri(@"\Images\Egg.png", UriKind.Relative));
imag.ImageFailed += (s, ea) =>
{
throw new Exception(ea.ErrorException.Message);
};
This however keeps throwing the above error nomather what I try.
The images are set as a resource and “Do Not Copy”.
- What am I doing wrong??
- How can I make the images work?
[Edit]
After comments I noticed the image is loading in the original project.
But I have a user control in a different project to which I send the image. From there the loading still fails.
How can I fix this?
Am I missing anything?
This is a terrible generic error message but I believe the problem may simply be that the files can’t be found. When you add items to your Silverlight project they don’t get copied out to the
ClientBinfolder of the hosting site (even on build, regardless ofCopy to output directorysettings because this only dictates what makes it to the current project’sbinfolder) – you’ll need to copy these manually (or eventually use a post-build step), that is:ClientBinfolder, alongside the.xapfile.Update:
So, there’s no website part of the solution, are the resources making it to the
binfolder of the Silverlight project itself? If not, try this:BuildActiontoContentCopy to output directorytoCopy Always, orCopy if newer