Silverlight 3: BitmapImage.SetSource - Catastrophic failure - by Malobukv

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 436047 Comments
Status Closed Workarounds
Type Bug Repros 13
Opened 4/29/2009 5:03:03 AM
Access Restriction Public


System.Exception was unhandled by user code
  Message="Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"
       at MS.Internal.XcpImports.CheckHResult(UInt32 hr)
       at MS.Internal.XcpImports.BitmapImage_SetSource(BitmapImage bitmapImage, CValue& byteStream)
       at System.Windows.Media.Imaging.BitmapImage.SetSource(Stream streamSource)
       at SilverlightApplication3.MainPage.Test(Object sender, RoutedEventArgs e)
       at System.Windows.Controls.Primitives.ButtonBase.OnClick()
       at System.Windows.Controls.Button.OnClick()
       at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
       at System.Windows.Controls.Control.OnMouseLeftButtonUp(Control ctrl, EventArgs e)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
Sign in to post a comment.
Posted by Andrew174 on 4/22/2011 at 2:03 PM
With regards to the two comments above:

I have closed the issue because I could not repro it with SL4, or the current development bits for SL5. If a full repro case is uploaded that shows a BitmapImage.Source being set to a valid MemoryStream containing complete, uncorrupted contents originating from a correctly encoded PNG or JPG image, I'd take a another look at this.

I *could* repro the secondary issue mentioned where the jpg stream is clipped, but this constitutes corruption of the contents. Our SL image decoder unfortunately cannot handle incomplete image data.
Posted by OptioBrian on 1/7/2011 at 8:23 AM
This is still broken in SL 4 (just installed and patched a few days ago).
Client-side I am simply decoding a small Base64-encoded BMP file (sent from my server via a REST service) then trying to create a ImageSource to bind to a image control.

                byte[] imageBytes = Convert.FromBase64String(picData);
                using (MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
                    BitmapImage im = new BitmapImage();
                    return im;

I get the catestropic error message on the "im.SetSource(ms);" line. I have confirmed that the byte array decoded on the client side matches EXACTLY to the byte array encoded on the source side. I have confirmed that I am using a BMP (hint from other posts).

Has this issue been reopened for SL4?
Posted by CalvinD2 on 5/13/2010 at 9:06 AM
I'm able to reproduce this issue.

See my post:
Posted by Chakris on 5/9/2010 at 9:50 PM
I am encountering this exception with .jpg and .png files in SL 3 Business Application Template. Is there any work around to handle this exception ??
Posted by Welsh-Wizard on 4/19/2010 at 8:47 AM
Any news on whether this is actually a bug in SL? and has it been fixed? I am using SL3 and using the following code

byte[] imageBytes = Convert.FromBase64String(base64String);            
MemoryStream ms = new MemoryStream(imageBytes);
BitmapImage img = new BitmapImage();            

Still gives the catastrophic failure error!

Any ideas?
Posted by Zortkun on 4/3/2010 at 10:05 AM
Same here. SL3 - JPG format
Posted by TheDoctor30306 on 1/7/2010 at 5:48 PM
I am experiencing this problem using SL3 and JPG format??????

Not fixed....
Posted by Anonymoussdffxgfgffcbcbcvb on 11/12/2009 at 10:37 AM
Hello, why has this bug been closed off? It persists in SL3 and renders the display of byte arrays absolutely useless!
Posted by Microsoft on 7/14/2009 at 3:41 PM

This issue should be fixed in Sivlerlight 3. I'm going to go ahead and close this issue as fixed. If you have any questions or are still expriencing the failure reactivate the bug.


Andy Rivas
Posted by bob_in_massachusetts on 5/7/2009 at 10:10 AM
I'm seeing this in Silverlight 2 with larger images.
Posted by Microsoft on 4/30/2009 at 12:25 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(
Posted by Microsoft on 4/30/2009 at 12:25 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(