Vista allows embedding 256x256 png images inside of .ico files. This can be generated, for example, by an application such as IcoFX. Unfortunately, at least as of .NET 3.0, the WPF Window Icon cannot accept this. The problem does not lie in the IconBitmapDecoder, but appears to lie in the Window code. To set the Icon property in code, we can do the following:
IconBitmapDecoder ibd = new IconBitmapDecoder(s, BitmapCreateOptions.None, BitmapCacheOption.Default); this.Icon = ibd.Frames[0];
Where "s" is your .ico stream. If you have a Vista-style .ico file, setting Icon will trigger the "image format is unrecognized" error. The only way to resolve this is to generate the .ico without the Vista images*.

Now, take a cleansing breath, smile, and get back to work.

Comments (3)
You are a pimp! Thanks for posting this... you saved the day.
Posted by MichaelD! | February 5, 2009 1:33 PM
Posted on February 5, 2009 13:33
You are a pimp! Thanks for posting this... you saved the day.
Posted by MichaelD! | February 5, 2009 1:33 PM
Posted on February 5, 2009 13:33
extinction compliance decade taken android
Posted by raedmundgo | May 8, 2009 8:07 AM
Posted on May 8, 2009 08:07