Skip to main content

Microsoft Silverlight

ImageError error #4001 in control 'ctl00_Main_Silverlight2'RSS Feed

(0)

ekleeman
ekleeman

Member

Member

59 points

42 Posts

ImageError error #4001 in control 'ctl00_Main_Silverlight2'

This error only occurs when using Slide.Show2 or PageTurn2 from my web server. Other Silverlight apps I have work perfectly.

Who knows what the problem is? Both apps work perfectly on the local VS webserver so it must be a Silverlight BUG.

BTW, I do not have two images the same name and the images are under the XAP file location.

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: ImageError error #4001 in control 'ctl00_Main_Silverlight2'

This error is thrown when it can't find the image so how you're hosting it is probably hitting you that relative URI's are being mapped differently on your server. Its likely a "site of origin" uri issue:

http://wildermuth.com/2008/06/23/Silverlight_s_XAML_Relative_URI_s_and_Site_of_Origin

BTW, this error is not trappable in .NET, you have to trap it via the OnError handler of the control itself (silly, yes, but the fact right now).

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

ekleeman
ekleeman

Member

Member

59 points

42 Posts

Re: ImageError error #4001 in control 'ctl00_Main_Silverlight2'

My path is the same in reference from the xap file locally and on my web server. The xap is in root/Public/ the images are in root/Public/Gallery/*

This works perfectly locally with the development web server in VS. Just as an experiment I tried putting the images in the same path as the xap file and even included the images in the xap file and still had the same error.

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: Re: ImageError error #4001 in control 'ctl00_Main_Silverlight2'

So locally its something like: http://localhost:8888/root/Public/Gallery/*.png and on the server its: http://mydomain/root/Public/Gallery/*.png If you are using a Website not a webapplication then the URI's will be different on teh server. Perhaps you could share what the full URI's (including fake server names if necessary).

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: Re: ImageError error #4001 in control 'ctl00_Main_Silverlight2'

Also, it could be that the IIS server is failing to give access to those images for other reasons (the image extensions are mapped as MIME types, security of the folder isn't available). Can you navigate to the images manually on teh server? If not, its an IIS setup issue, not Silverlight.

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

ekleeman
ekleeman

Member

Member

59 points

42 Posts

Re: Re: ImageError error #4001 in control 'ctl00_Main_Silverlight2'

Actually the 2 apps I'm trying to implement use the same technique,

ImageElement.Source = new BitmapImage(new Uri(Application.Current.Host.Source, Source));

Where Source is supposed to be a relative Uri based on a string like Gallery/KohTao/KohTao1.jpg, which works locally but not on my dedicated server

I've heard everything from filename duplicates, path non existent, or latentcy that causes WebClient.DownloadAsync to return a false positive.

On the same web site I have my own Silverlight app that loads XAML code programatically for example:

panel12img1Xaml += "<Image xmlns='http://schemas.microsoft.com/client/2007' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' Height='115' Margin='-13.5,-7.814,78.5,-21.186' Width='115' Canvas.Top='47' Canvas.Left='5' Source='bigben.png' Stretch='Fill'/>";

Image panel12img1 = XamlReader.Load(panel12img1Xaml) as Image;

this.panel12Canvas.Children.Add(panel12img1);

The XAP for this is in a subfolder with the same permissions as the other subfolder that fails to load images using a Uri.

At this point I'm shelving the Silverlight Slide.Show2 and Pageturn2 Gallery apps until this issue is resolved by the developers or MS. I could probably fix it but I have other things I'd rather be working on.

Thanks anyway.... Se La Vie

BTW, this Slide.Show Gallery worked fine under Silverlight 1.2 but not Silverlight 2.0 but I don't want to require my visitors to download an old version of a plugin.

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities