I created a WPF Window and made it a MEF Export.
I can do a ShowDialog once on the MEF Import but the second time it aborts because the MEF component was closed by the first ShowDialog.
What can be done to allow repeats of ShowDialog?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
When you call ShowDialog on a WPF window twice like this:
you will get an
InvalidOperationExceptionwith this message:To fix this, you need to recreate the window each time, e.g. like this:
To do this in MEF, you could export a separate controller component which is responsible for creating and then showing your dialog (rather than exporting your dialog directly):