Sometimes it blows me away to see an error message that is so confusing that I don’t wonder why people get frustrated with new technology. Take for instance this error you might see when building a WPF application. I had a WPF application that I was polishing and happened to add a background to a report page. It took me several minutes to determine what the problem was because, as you can see, the error didn’t really indicate clearly what the problem was.
The root cause was that when I added the Grid.Background, I had not provided a path and the file was in the solution directory, so it looked fine during design but failed when I tried to run the application.
The fix was simple, I put the file on a hosted share and gave a web URL for the image.
I hope that helps someone avoid the headache I had.
** One additional note ** Changing the target framework to 3.5 clarified the error greatly. Kudos to the 3.5 .Net guys. ***
Happy Coding!
Another comment. If you do want to use an image and keep it in your solution folder and then just reference it from wherever the application is, simply use “./” for the path on your ImageSource attribute. Example: