We have a C# WPF project (.NET 4.0, Visual Studio 2010). It has been tested on both Windows XP and Windows 7 and seems to work fine, but now I have received reports from two customers on the field (both located in Spain for some reason) who cannot start the software.
Looking at the log file I see that they get "The image format is unrecognized" exception (Caused by: Exception from HRESULT: 0x88982F07).
I have googled on the error and I have found that this seems to be that WPF fails to load the Vista PNG icon on Windows XP. But those reports are a couple of years old, surely Microsoft resolved it by now (?), and in my case it works fine on most XP installations. I really don't want to limit the icon appearance on more recent Windows.
The most common use of our application is on Laptops, and one of the users reported that when he connected his laptop to an external monitor the problem got resolved. And when I asked the other one to test the same thing he had the same result.
So my questions are: Do you know if this problem has been resolved by Microsoft? Do you know why it only happens on some Windows XP instances and how it is related to the monitor? And most importantly, do you know what I could do to make our application more robust to this without changing the icon?
I had the same error today, out of the blue, and only on my development machine. The WPF implementation seems to be still buggy.
If I understand this (article) right, it can occur everywhere ICO files are read. In my case it was while setting an icon for the main application window in XAML:
<Window x:Class="MyApp.MainWindow" Icon="Dashboard.ico" >
The above code failed suddenly, but using a PNG file solved the problem:
<Window x:Class="MyApp.MainWindow" Icon="Dashboard.png" >
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.
this issue has had me pulling my hair off for quite a long time, and I have spent quite a while trying to figure out what was going on so I'll share my conclusions since it might help someone else (possibly even myself in the future) :
this issue appears mainly on windows XP and/or when connecting via remote desktop (especially on windows server). But it is kind of random and impossible to replicate on purpose
those links provide a good explanation as well as a solution/workaround : http://code.logos.com/blog/2008/08/image_format_error_when_loading_from_a_stream.html https://github.com/LogosBible/Logos.Utility/blob/master/src/Logos.Utility/IO/RebasedStream.cs
using a png file directly will work, but it has its limitations (for instance, I use .ico files so as to have multiple images depending on the size of the displayed icon and a .png file cannot replace a .ico file for this purpose)
the best answer - and what I ended up doing - is what Joachim said in his comment of the OP's question :
https://social.msdn.microsoft.com/Forums/vstudio/en-US/9e723d51-0e26-4609-8fe1-5e0edcf7385b/setting-windowicon-to-vista-256x256-png-icon-causes-a-fileformatexception?forum=wpf seems to indicate it'll resolve itself if you don't compress the icon. – Joachim Isaksson Jan 23 '12 at 12:44
so I looked up in icoFx (that I use for my icon editing) and sure enough :
I simply unchecked this and saved my .ico again (size went from 30Kb up to 286Kb in the process!) and voilà!
problem solved
User contributions licensed under CC BY-SA 3.0