Home Dashboard Directory Help
Search

WPF application fails if Window.Icon is a Vista .ico file by Appel


Status: 

Closed
 as External Help for as External


35
0
Sign in
to vote
Type: Bug
ID: 321285
Opened: 1/7/2008 4:05:36 AM
Access Restriction: Public
4
Workaround(s)
view
31
User(s) can reproduce this bug

Description

If a Vista icon, that contains png-image, is used as Window.Icon the application fails to launch with an FileFormatException.
Details
Sign in to post a comment.
Posted by 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.
Posted by flöle 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.
Posted by figuerres 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.
Posted by unreal128 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.
Posted by Carsten Witte 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...
Posted by Xlfdll 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...
Posted by Wojciech.Gebczyk 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.
Posted by Steven W_ on 8/24/2008 at 10:27 PM
We can take the time to support custom Pixel Shaders, but not Vista icons?
Posted by Microsoft 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.
Posted by Scandalon on 3/4/2008 at 9:45 AM
What is the usual turnaround on these types of issues?
Posted by Microsoft 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.

Thank you,
Visual Studio Product Team
Posted by Microsoft 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.”

Thank you,
Visual Studio Product Team
Sign in to post a workaround.
Posted by Ueli on 1/7/2014 at 7:55 AM
Under display settings, Appearance, Color Scheme: Set it to "Windows Standard" instead of "Windows Standard (extra large)".
Posted by drewkeller 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[0];
Posted by BenWatkins 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);
        }
}
Posted by awe 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).