Setting Window.Icon to Vista 256x256 PNG icon causes a FileFormatException RRS feed

  • Question

  • If I set the Icon property to a Vista icon, I get a FileFormatException stating that the image format is unrecognized. If I try the same thing with an old Windows XP icon (without PNG compressed images) it works correctly. I simply cannot believe that WPF doesn't support Vista icons.


    Thursday, January 4, 2007 4:46 PM

All replies

  • Can vista use pure png-images as icons?!


    I've always wondered why windows has been stuck to those lame ico-files to which it's almost impossible to find a good converter for.

    Thursday, January 4, 2007 7:59 PM
  • Well, Vista still uses .ico files, but now has the ability to have icons up to 256X256 pixels. To save hard disk space, these large bitmaps are compressed with png in the .ico file.


    Thursday, January 4, 2007 10:53 PM
  • Any ideas as to why this is happening?
    Saturday, January 6, 2007 5:19 PM
  • Can you email me the PNG file?
    Monday, January 8, 2007 5:11 PM
  • I have e-mailed you the file



    Monday, January 8, 2007 9:33 PM
  • I get an even weirder problem. My icon displays OK the first time, but the second time I try to display it I get the same FileFormatException. I tried removing the 256x256 image from the icon and now it works OK regardless of how many times I display it.

    Wednesday, February 14, 2007 10:43 PM
  • Any new news on this?

    I'm using a Vista icon too when I ran into the "The image format is unrecognized" error.

    Hopefully they'll fix this with the next release. It would be pretty embarrassing if WPF cannot support Vista icons.

    Friday, March 16, 2007 3:09 AM
  • When you save the icon file with a 256x256x32 size picture without PNG-compressing the picture, WPF seems to be able to cope with it.

    For example in Axialis Icon Studio you can rightclick the icon and disable the PNG-compression. I reckon there are other tools to do the same thing out there somewhere.

    • Proposed as answer by Cory Plotts Thursday, November 14, 2013 5:47 PM
    Friday, October 19, 2007 9:56 AM
  • Hello,

    Recently I installed MS Blend 3, and I'm facing the same issue using compresses vista format (256x256x32). The only workaround I found so far is no compressing the images.

    Is this STILL the only way?


    Project Manager at INOVATIVA Tecnologia www.inovativatec.com
    Friday, July 31, 2009 1:33 PM
  • I love bringing up a three-year old thread, but doing some research I came across this issue.

    Oddly, a few coworkers have been getting this issue with an in-house produced Visual Studio Add-on. However, the issue didn't appear (meaning that the Add-on was working fine in their systems) until they installed .NET 4.0 and VS2010. I'm running Win7 and do not get the issue - however, the ones with the issues are running XP.

    So something with installing VS2010 or .NET 4.0 caused this issue to rear its ugly head on XP. It worked on the same machines with .NET 3.5 and VS2008 installed.

    Wednesday, June 23, 2010 4:41 PM
  • I am using .NET 4 with VS 2010 pro on Window 7. My software displayed some .ico files. It is working good on window 7 but window vista are showing problems like not displayed icon on second time , delay atcs.

    I just remove 256 by 256 image from ico file and it is working smoothly on vista also.

    This exp might help somebody.

    Friday, July 2, 2010 3:25 PM
  • Very annoying bug to track down, my developer machine is currently XP (still targeting customers using XP)

    The 256x256 png icons work fine in on XP, both running from debug/release and also from outside Visual Studio as an installed app.

    It only crops up when using the application on any other machine. Not sure what dependency I've got installed in my dev PC to make the icon work.

    • Proposed as answer by CIX80 Wednesday, June 6, 2012 4:10 PM
    • Unproposed as answer by CIX80 Wednesday, June 6, 2012 4:10 PM
    Friday, September 10, 2010 12:38 PM
  • Try this:

    Use IcoFx, for example, to create your icon and don't compress the images:

    1. Uncheck this: Tools->Preferences->Tools->Compress the images 256x256 for Windows Vista
    2. Create your icon
    3. Run your app in Windows XP

    Have you solved it? :D

    Wednesday, June 6, 2012 4:20 PM
  • I also encountered a similar problem on Windows 2008 Standard SP2.

    The exception is:

    Timestamp: 2013/3/15 4:10:38

    Message: HandlingInstanceID: 52a32845-c463-4d0d-b1c9-824dcab5ba3d
    An exception of type 'System.IO.FileFormatException' occurred and was caught.
    03/15/2013 12:10:38
    Type : System.IO.FileFormatException, WindowsBase, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35
    Message : 图像格式无法识别。
    Source : PresentationCore
    Help link : 
    SourceUri : 
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Void EnsureThumbnail()
    Stack Trace :    在 System.Windows.Media.Imaging.BitmapFrameDecode.EnsureThumbnail()
       在 System.Windows.Media.Imaging.BitmapFrameDecode.get_Thumbnail()
       在 MS.Internal.AppModel.IconHelper.GetBestMatch(ReadOnlyCollection`1 frames, Size size)
       在 MS.Internal.AppModel.IconHelper.CreateIconHandleFromImageSource(ImageSource image, Size size)
       在 MS.Internal.AppModel.IconHelper.GetIconHandlesFromImageSource(ImageSource image, IconHandle& largeIconHandle, IconHandle& smallIconHandle)
       在 System.Windows.Window.UpdateIcon()
       在 System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
       在 System.Windows.Window.CreateSourceWindow(Boolean duringShow)
       在 System.Windows.Window.CreateSourceWindowDuringShow()
       在 System.Windows.Window.SafeCreateWindowDuringShow()
       在 System.Windows.Window.ShowHelper(Object booleanBox)
       在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       在 MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

    If I remove 256X256 image, this problem can be sovled.

    As followed:


    Saturday, March 16, 2013 2:50 AM
  • I know this is very old now but I've had a bit of fun with this problem this morning.  It turned out that the error was occurring only on XP machines where the colour settings were set to 16 bit, and when I changed it to 32-bit the problem magically disappeared.

    This goes for XP (including Embedded) SP3.

    Wednesday, June 11, 2014 7:29 AM