C# WPF catch exception in subform called by winform
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 prob开发者_开发技巧ably 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.
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
精彩评论