XamlParseException on BitmapImage

Home Grown Coder

Well-known member
Joined
Nov 16, 2012
Messages
52
Location
Bay Area, CA
Programming Experience
3-5
I'm running into a XamlParseException when loading a WPF start page for our application (sort of like the VS start page) and it is caused by a corrupted image file that it's trying to load into a BitmapImage. My problem is I can't find a way to catch the exception so that I can hide/turn off the start page and allow the application to continue. Here are some details of my setup:

  • an RSS feed is cached locally as an XML file on the client machine, along with any supporting image files (this provides offline capability)
  • the XAML markup includes a XmlDataProvider resource pointing to the XML file from the first bullet
  • the XAML UI has a ListBox with its source bound to the StaticResource from the second bullet
  • the ListBox ItemContainerStyle points to a StaticResource style that sets the ControlTemplate for the ListBoxItem. This ControlTemplate contains the BitmapImage that is trying to load the corrupted image file that was cached in the first bullet
To complicate matters, this WPF control is hosted inside an ElementHost in Windows Forms.

I've tried putting InitializeComponent of the WPF control and the Windows Form into Try/Catch blocks, but that didn't work. I've also tried Try/Catch blocks around the code in Load, etc. I can't get a call stack and IntelliTrace is also not helping. Any ideas how/where I can catch this exception?

If all else fails, I may need to remove the data binding and fill the listbox manually so that I can catch any problems with the image files.

Thanks in advance for any advice!
Home Grown Coder
 
Back
Top