1
votes

I have a WPF application that calls a winforms subform. The winform calls a WPF window using showDialog(). The WPF window contains borders that I am setting the background image of. My problem is this. If an image that is being loaded has a problem, I get an ArgumentException telling me the image has an invalid metadata header. Even if I catch the error, the WPF sub window still loses focus behind the other two windows and any interaction with it that would set the dialogResult to true cause an InvalidOperationException because it doesn't register the window as having been called by showDialog().

I'm probably doing something blatantly wrong. However, how should I be handling this exception, and why does the WPF sub window behave this way?

Edit: The exception seems to occur whenever I set the uri or stream source of a bitmapImage. However, placing this into a try block doesn't cause it to be caught here, it is caught in the showDialog() call.

1
I didn't figure out my issue, but I did find a work-around. I used example 1 in this question: stackoverflow.com/questions/5682822/…radicalpi

1 Answers

-1
votes

Not trying to solve the problem but make a joke:

a WPF application that calls a winforms subform. The winform calls a WPF window using showDialog()

That is the root of all problems :D