XamlParseException and 256x256 icons
When testing out a WPF app on XP I got an unhelpful XamlParseException error report.
I was a little puzzled because I was hooking up error reporting in App.xaml.cs:
My error handler was attempting to create a XAML window to report the error, and evidently this was bombing out as well triggering the good doctor Watson. I added a MessageBox call instead and discovered that the XamlParseException was wrapping a FileFormatException and the stack trace indicated that the problem was with setting the icon for the window. After removing the icon the app started up fine. Weird.
It turns out that WPF chokes on a compressed 256x256 icon on XP and Vista (Windows 7 seems to cope fine). Saving the icon without compression fixes the problem. I use IcoFX and you can set this at Options -> Preferences -> Options -> Compress 256x256 images for Windows Vista. Of course the consequence is that the icon is a couple of hundred kilobytes larger.
Related Posts
- UAC shield icon in WPF
- BadImageFormatException for a 64-bit ASP MVC web application
- Crushing PNGs in .NET
- Merging Resource Dictionaries for fun and profit
- The Secret Diary of a Xamarin Android Developer, Aged 48 1/3
(Published to the Fediverse as: XamlParseException and 256x256 icons #code #xaml #wpf #wtf You can't use a compressed 256x256 icon with WPF but you can include an uncompressed version. )
Comments
Thank you. Just, thank you.
Add Comment
All comments are moderated. Your email address is used to display a Gravatar and optionally for notification of new comments and to sign up for the newsletter.