"Image format is unrecognized" when setting WPF Window Icon
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;
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.