Visual Studio and .NET Framework Home
WPF application fails if Window.Icon is a Vista .ico file
1/7/2008 4:05:36 AM
User(s) can reproduce this bug
If a Vista icon, that contains png-image, is used as Window.Icon the application fails to launch with an FileFormatException.
.NET Framework 3.5
Windows XP Professional
Operating System Language
Steps to Reproduce
Create a WPF application.
Add one of the WinVista icons from VS2008ImageLibrary as a resource to the project.
Set the Window.Icon property to the .ico resource.
A FileFormatException is thrown, "The image format is unrecognized.".
The icon is used as window icon.
TAP Code (if applicable)
You can indicate your satisfaction with how Microsoft handled this issue by completing this quick
3 question survey
to post a comment.
Please enter a comment.
Blake A Niemyjski
on 5/30/2012 at 4:09 AM
I just ran into this behavior on Windows XP and WPF 4. There is no reason why this bug exists FIX it and don't close it by design.
on 5/18/2011 at 3:02 AM
Experienced the issue just now, on XP with .NET 4.0. To me it is absolutely not acceptable that such serious bugs can persist for so long. As pointed out earlier, WPF is hard enough to learn anyway, it shouldn't be necssary to deal with such problems.
on 6/11/2010 at 3:44 PM
I built an app and used an ico file that works on WIndows 7 and had the customer asking why the app crashes on XP.
also the same ico works on the first form the app opens but not on a second form? WTF?
the unrecognised image format exception at runtime is really nasty!
handle the exception at runtime and add a check when the app compiles that the icon format selected is not compatable with XP!
XP may be end-of-life today but there are a lot of PC's running XP that will still need to have apps installed on them for a while yet.
on 2/23/2010 at 1:19 PM
This was a pretty frustrating bug. Took an hour between me and another developer to find out this was flagged as a problem. As a new WPF user, it is hard enough to learn the new architecture but then to spin your wheels on an issue like this can generate a lot of disgruntlement.
on 4/26/2009 at 2:45 PM
When you deliver a package VS2008, WPF and a bunch of icons, that package shall be supported. It's that simple...
on 2/27/2009 at 6:18 AM
This is a stupid bug...I think...
WPF managed programs runs on Vista recommend, but not support Vista icons...
on 11/12/2008 at 6:31 AM
I understand that you have more cool features to do, but fixing it to not crash on ANY member access would be sufficient fix.
Right now there is no way to iterate over Frames collection without exception generating. In some scenarios event using try-catch approach is not solution as introduction of try-catch involves creation additional code.
ITS REALLY important to AT LEAST not throw exception. Better solution would be to be able programatically check for unsupported frame types/formats.
on 8/24/2008 at 10:27 PM
We can take the time to support custom Pixel Shaders, but not Vista icons?
on 7/28/2008 at 2:03 PM
This is a new icon format that was introduced with Vista and is not yet supported by WPF/Windows Image Codecs.
on 3/4/2008 at 9:45 AM
What is the usual turnaround on these types of issues?
on 1/7/2008 at 9:30 PM
Thanks for your feedback.
We are escalating this issue to the appropriate group within the Visual Studio Product Team for triage and resolution.
These specialized experts will follow-up with your issue.
Visual Studio Product Team
on 1/7/2008 at 9:27 PM
Thank you for your feedback. We are currently investigating. The investigation process normally takes 7-14 days. If this issue is urgent, please contact support directly (see http://support.microsoft.com).
If at any time your issue is closed unsatisfactorily, you may edit your issue via Connect and change the status to “Active.”
Visual Studio Product Team
to post a workaround.
Please enter a workaround.
on 6/1/2012 at 8:26 PM
In my testing, 1 out of 3 computers running Windows XP SP3 had a problem with an icon that contained a 256x256 frame. I'm not sure what was different on that machine. Anyway, the default settings of my icon generator was outputting that frame as a compressed PNG. When I configured it to output uncompressed PNG, XP worked fine with it. The filesize of the icon went from around 60k to 200k+, but apparently it's more universal.
The code I"m using looks like this...
Uri u = new Uri("pack://application:,,,/myAssembly;component/AppIcon.ico", UriKind.Absolute);
var ibd = new IconBitmapDecoder(u, BitmapCreateOptions.None, BitmapCacheOption.Default);
mainWindow.Value.Icon = ibd.Frames;
on 3/28/2012 at 2:42 AM
Another work around that worked for me is this:
- Remove icon from the window
- Set the icon in the Application Properites (in windows XP your app will use this icon for the window, but not in windows 7)
- use the following code to determine if the OS is above XP, if it is, then add the icon back in
private void Window_Loaded(object sender, RoutedEventArgs e)
if (Environment.OSVersion.Version.Major > 5)
Uri iconUri = new Uri("pack://application:,,,/Icon.ico", UriKind.RelativeOrAbsolute);
this.Icon = BitmapFrame.Create(iconUri);
on 5/19/2009 at 11:32 PM
Make sure the icon has max size 64x64 pixels.
It can still be 32 bit (using alpha channel).
© 2013 Microsoft