开发者

Creating BitmapImage from MemoryStream causes crash - used to work

I'm really perplexed at this. I'm creating a BitmapImage with a开发者_如何学编程 raw byte array like so:

void SetBitmapData(byte[] imageData)
{
    var bitmapImage = new BitmapImage();
    bitmapImage.BeginInit();
    bitmapImage.StreamSource = new MemoryStream(imageData);
    bitmapImage.EndInit();

    this.Bitmap = bitmapImage;
}

Until an hour ago, it worked - and had been working for months. Now, on bitmapImage.EndInit(), it's giving me a NotSupportedException - "No imaging component suitable to complete this operation was found."

I'm really confused because as of this morning, this worked. Nothing has changed. In fact, to make sure that my changes (which were in completely unrelated parts of the application) weren't causing the crash, I checked out the code fresh from SVN using the head. The head did not crash yesterday when I committed it. This fresh copy also exhibits the same behavior.

It crashes from VS and when running the executable itself.

I'm running Visual Studio 2010 with the following plugins: ReSharper, StyleCop for ReSharper, VisualSVN.

Right before this started happening, Visual Studio did something odd - the keyboard cursor disappeared, but I could still type. I could select multiple characters with the mouse and keyboard, and, if I hit 'Delete' they would be deleted. I restarted Visual Studio, and the invisible cursor problem went away.

I've tried rebooting my computer, but that didn't help.


"No imaging component suitable to complete this operation was found." gets thrown when the call to IWICBitmapEncoder_Initialize_Proxy fails. Because your VS2010 (which also uses this stuff) is acting funny as well I'm guessing that some of your dlls are hosed. Your best bet may be to ask how to restore Windowscodecs.dll and Wincodec.lib on SuperUser

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜