Skip to main content

Microsoft Silverlight

Answered Question 4001 Image ErrorRSS Feed

(0)

mwrand12
mwrand12

Member

Member

8 points

5 Posts

4001 Image Error

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: 

<Canvas xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="640" Height="480" x:Name="Page">

<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
Cass

Contributor

Contributor

3157 points

654 Posts

Re: 4001 Image Error

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
Jhorra

Member

Member

522 points

475 Posts

Re: 4001 Image Error

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. 

mwrand12
mwrand12

Member

Member

8 points

5 Posts

Re: Re: 4001 Image Error

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 

 

 

Cass
Cass

Contributor

Contributor

3157 points

654 Posts

Re: Re: 4001 Image Error

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
Jeff Paries

Member

Member

606 points

106 Posts

Re: 4001 Image Error

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
 

mwrand12
mwrand12

Member

Member

8 points

5 Posts

Re: Re: 4001 Image Error

Cass,

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.

 

 

Cass
Cass

Contributor

Contributor

3157 points

654 Posts

Re: Re: 4001 Image Error

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?  

 

mwrand12
mwrand12

Member

Member

8 points

5 Posts

Re: Re: Re: 4001 Image Error

Cass,

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.

 

 

Jeff Paries
Jeff Paries

Member

Member

606 points

106 Posts

Re: Re: 4001 Image Error

Michael,

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.

 

Jeff
 

mwrand12
mwrand12

Member

Member

8 points

5 Posts

Re: Re: Re: 4001 Image Error

Jeff,

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!

 

 

 

 

 

Jeff Paries
Jeff Paries

Member

Member

606 points

106 Posts

Answered Question

Re: Re: Re: 4001 Image Error

Glad to hear you got it working.

Yes, definitely steer clear of GIFs. PNG or JPG only.

Jeff
 

dewde
dewde

Member

Member

22 points

12 Posts

Re: 4001 Image Error ImageError

Silverlight error message

ErrorCode: 4001

ErrorType: ImageError

Message: AG_E_NETWORK_ERROR

 

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
ilPadrino

Member

Member

2 points

1 Posts

Re: Re: 4001 Image Error ImageError

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
alexdg

Member

Member

8 points

5 Posts

Re: Re: 4001 Image Error ImageError

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.

Jeff Paries
Jeff Paries

Member

Member

606 points

106 Posts

Re: Re: 4001 Image Error ImageError

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.

Jeff 

dewde
dewde

Member

Member

22 points

12 Posts

Re: Re: 4001 Image Error ImageError

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.

peace|dewde
 

alexdg
alexdg

Member

Member

8 points

5 Posts

Re: Re: Re: 4001 Image Error ImageError

sad... i guess we'll put it together with missing align text feature.

zenluiz
zenluiz

Member

Member

29 points

35 Posts

Re: Re: Re: Re: 4001 Image Error ImageError

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!

dewde
dewde

Member

Member

22 points

12 Posts

4001 Image Error ImageError

Zenluiz: Very good critical thinking. Thanks for sharing! peace|dewde http://dewde.com

atconway
atconway

Member

Member

52 points

106 Posts

Re: Re: Re: Re: 4001 Image Error ImageError

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.

Thank you,   >[Blog]<

"The best thing about a boolean is even if you are wrong, you are only off by a bit." :D
-anonymous

gamlefar
gamlefar

Member

Member

2 points

1 Posts

Re: Re: Re: Re: Re: 4001 Image Error ImageError

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 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities