2
votes

I have a large WPF app and recently we have had icons disappear. We have the images as external resources that get loaded into memory. We have a custom button template where we set an ImageSource for the icons to show up. I used procmon to see that the image files are loaded into memory. I used WPF Snoop to see that the buttons have the images set correctly. Only some of the icons will disappear and then if you start the app again they might all be there. Using snoop if I change the imagesource to one of the files that loaded and are displayed, then that one will also show up, but if i put a "bad" one into a button that loaded fine before, the icon is still gone. When they disappear it is the same ones that disappear. And occasionally the wrong icon all together will appear on one of the buttons.

The button template has an Imagesource setup for the image to load and display.

This is really puzzling because one time everything loads just fine and the next, some of the icons are not loading. They are all png files.

Any ideas where to look next? Thanks.

1
When you debug, do you get any messages in the Output window along the lines of "unable to find resource" or similar?RQDQ
ProcessMonitor shows the entire file is being read into memory. It shows the open, reading the entire file size and then closing the file. There is no outputs that are stating that it cannot find a resource. These are external resources, so it is loading up an external file that is not compiled as a resource at all.SteveM

1 Answers

0
votes

One reason I can think of is that you just have one instance of each image, so if you use it one place it will disappear in other places. If you have the resources defined in XAML you can set x:Shared="false": http://msdn.microsoft.com/en-us/library/aa970778.aspx Otherwise you'd have to create additional instances manually from your code.