Skip to main content
Home Forums General Silverlight Getting Started 4001 Image Error
21 replies. Latest Post by gamlefar on April 24, 2009.
(0)
mwrand12
Member
8 points
5 Posts
11-21-2007 9:05 PM |
I tried creating my first Silverlight app today.
All was going great until I dropped an image control onto my canvas. As soon as I tried reference an image, I received a very unhelpful error:
<
<Image Width="250" Height="250" Canvas.Left="188" Canvas.Top="87" Source="1.png" Stretch="Fill"/>
</Canvas>
My image file is in the same directory as my xaml. I am not doing anything fancy. Whether I host the app on my personal computer in localhost or on our Windows Server, I get the same error.
The error message is:
Silverlight error message
ErrorCode: 4001
ErrorType: ImageError
Message: AG_E_NETWORK_ERROR
Thanks,
Michael
Cass
Contributor
3157 points
654 Posts
11-21-2007 10:40 PM |
There is no assembly information on this canvas, you should let Silverlight app know where to build the assembly, like
xmlns:ProjectName="clr-namespace:ProjectName;assembly=ClientBin/ProjectName.dll" x:Class="ProjectName.Page;assembly=ClientBin/ProjectName.dll"
Are you using Silverlight 1.1 or Silverlight 1.0 ?
Jhorra
522 points
475 Posts
11-22-2007 12:11 AM |
Is the image in the same folder as the html page that's rendering your XAML? I'm pretty sure you have to map it from there, not necessarily where the XAML file is.
11-22-2007 11:24 AM |
Cass,
Thanks for reply.
I am using Silverlight 1.0.
When I add the projectname and class lines (changing them to point to my assemblies), I get a new error:
Error Code 2251
Message: AG_E_RUNTIME_MANAGED_ACTIVATION
It's frustrating because everything else seems to workfine. I just cannot add imge files to my Silverlight canvas -- which of course is my first assignment. :-)
-Michael
11-22-2007 12:10 PM |
I am sorry I presummed you were using Silverlight 1.1.
This error was reported earlier http://silverlight.net/forums/t/6097.aspx please provide more info about the error.
Jeff Paries
606 points
106 Posts
11-22-2007 1:17 PM |
Michael,
This code is fine and works when I tested it locally. Have you set up some type of subfolder or something for the XAML/images file?
If so, you may want to try moving the image to the root directory, or recreate the project all in one folder.
Jeff
11-22-2007 3:23 PM |
I am not sure what else I can report. Silverlight seems to be functioning as it should, except that when I try to add an image to my canvas I get the 4001 error. If I add the references to my assembly as you suggested I then get the 2251 error.
Jeff,
I get the error whether my images and xaml are in the root direct of the sample application or in subdirectories.
11-22-2007 3:55 PM |
I asked you to add assembly info as I thought you were using Silverlight 1.1, you dont need them for Silverlight 1.0. What is the Silverlight version installed on your computer (right click on Silverlight page in Browser and select Silverlight Configration)?
Are you using Expression Blend 2 Sept Preview to add the image on your canvas? If not then try to just drag and drop the image on the Canvas in Expression Blend from the project tab. Can you see the preview of the image in Design section of Expression Blend?
11-22-2007 4:12 PM |
Straight from the horses mouth: Version: 1.0.21115.0
I am using Expression Blend 2 Sept Preview.
And yes, I can preview the image on the canvas within Blend. However, if I try to test the solution (F5), I get the same error.
11-22-2007 4:23 PM |
If you want to zip up your project and email it to me, I can look at it for you. Your XAML worked fine for me when I dumped a PNG file named 1.png in the project folder, so without seeing it, I'm not really sure what else may cause it.
My email address is my full name (above my avatar, no spaces) at Yahoo dot com.
11-22-2007 4:41 PM |
Okay, now I am really confused!
Here are the steps I think I took place:
1)In my first Silverlight app, I used a gif file
This caused my 4001 error (I just confirmed this)
2) The code I posted showed I was using a png file, and I swear I tried that before my first post.
3) Then still using the png file, I tried Cass's recommentation (based on his assumption that I using 1.1, not 1.0) of adding the assembly references. After I few dozen more tries I went back to using my gif file. And then followed a few more back and forth posts.
4) While cleaning up my project to send you, I removed the the references, and punt the png file back in, bacause that is what you said you tested with.
5) Voila! All is working! Talk about wasting 4-5 hours!
We definitely need to put in big red letters somewhere that you cannot import gifs onto your canvas. Within Blend there is a question mark over the gif icon, but when you add the gif to the canvas it allows you to preview it.?!?!
Happy Thanksgiving!
11-22-2007 5:22 PM |
Glad to hear you got it working.
Yes, definitely steer clear of GIFs. PNG or JPG only.
dewde
22 points
12 Posts
11-26-2007 1:44 AM |
I know this was answered, but I was getting this same error message and I resolved it a different way. My project was Silverlight 1.0 - javascript. I was downloading all my assets (XAMLs, images, etc) in a ZIP and using the downloader to access them. I had 3 secondary "screens" that would popup with a mouse click. Each of these screens was a separate XAML file in the ZIP package. On download complete I was grabbing each XAML and adding it to the root canvas of my Page.xaml. Then I wired up each asset on each page.
Here was my issue. One of my assets was logo_small.png, which was referenced on every "secondary screen". When I opened secondary screen #1 it would work fine. But after closing it (Collapse), I would get the 4001 ImageError on the subsequent screens #2 and #3.
Kind of stinks, it appears you can only have a 1-to-1 relationship between Image elements and assets in a ZIP package.
peace|dewde
ilPadrino
2 points
1 Posts
11-27-2007 3:28 PM |
I had the same problem, only you need change the file Page.xaml
and be careful to change the image source tag of others files, for example
<ImageBrush ImageSource="images/shadow.png" Stretch="None"/>
done!
alexdg
12-17-2007 12:22 PM |
I'm having the same problem as dewde with a more than one SetSource on the same image inside ZIP file. I hope this isn't the core of the problem and there's a workaround.
12-17-2007 12:56 PM |
I didn't get an error thrown, but I did get some unexpected behavior when the XAML had placeholder references in it. I had to make certain the Source of the XAML element was "" - I typically use something for positioning or spacing before adding the dynamic content in.
12-17-2007 1:00 PM |
The work-around for me was to just remove those images from the ZIP and reference them directly from the directory on the web server. Kind of sucks because now when a page loads and displays it may or may not show the logo right then. In some cases the logo won't pop until after the user has been viewing the page for a couple of seconds.
This is the only work-around I know of.
12-17-2007 6:06 PM |
sad... i guess we'll put it together with missing align text feature.
zenluiz
29 points
35 Posts
03-06-2009 9:20 AM |
Hi guys!
I know that some of you have solved this problem.
However, I'd like to share with you another reason why this problem can happen.
I faced this problem today with a simple XAML page with just one simple PNG image inside it.The image file was generated by 3D Studio Max.
When I run the project, I got an "ImageError AG_E_NETWORK_ERROR". Some attempts after, I tried something unusual: I opened the image with GIMP, saved it and run the project again... AND... VOILAAA! Now it worked!! :-)
The conclusion I came to is that sometimes the image file has something in it that Silverlight doesn't understand, may be the format, depth, palette color, etc.
Hope this info helps someone! ;-)
Cheers!
03-06-2009 9:44 AM |
Zenluiz: Very good critical thinking. Thanks for sharing! peace|dewde http://dewde.com
atconway
52 points
03-06-2009 2:52 PM |
zenluiz:
This may have had to do with the format of the .png not being supported, and the GIMP converted it to a Silverlight acceptable format inadvertently. This is from the MSDN (http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapimage(VS.95).aspx):
Silverlight does not support all possible color depths that are included in the PNG specification. The following are the PNG color depths supported in Silverlight:
Indexed color: 1-bit, 4-bit, or 8-bit color depth (per channel).
Truecolor: 24-bit color depth, or 32-bit color depth (per channel) for truecolor plus alpha.
Notably, gray scale (with or without alpha), and 64-bit truecolor, are not supported in Silverlight.
gamlefar
04-24-2009 5:53 AM |
I had the problem to. After viewing the xaml code, I found that i had a image source reference in the xaml code. After removing the source attribute from image in xaml code the error is gone.
Hope this info may solve your issue
Anders Samnøy
Http://www.samnoy.net