Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 816967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:55:11+00:00 2026-05-15T01:55:11+00:00

I created a WPF Window and made it a MEF Export. I can do

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:55:12+00:00Added an answer on May 15, 2026 at 1:55 am

    When you call ShowDialog on a WPF window twice like this:

    var window = new Window();
    window.ShowDialog(); // returns when user closes first window
    window.ShowDialog(); // throws 
    

    you will get an InvalidOperationException with this message:

    Cannot set Visibility or call Show or
    ShowDialog after window has closed.

    To fix this, you need to recreate the window each time, e.g. like this:

    var window = new Window();
    window.ShowDialog();
    window = new Window();
    window.ShowDialog();
    

    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):

    [Export]
    public class MyDialogController
    {
       public void ShowMyDialog()
       {
          using (var myDialog = new MyDialog())
          {
              myDialog.ShowDialog();
          }
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've created a WPF application with a frame inside. I can attach some other
I created a WPF Window than i modified its class definition to: public partial
I created a WPF test project, single Window with a single button in it.
is there a way to add a user control to a WPF Window created
I've created a WPF Window with a lot of buttons, each of them run
I have created the WPF user control and WPF window in class library project.
I have the following Window created in WPF. This is how it's shown: I
I am trying to create a child window in WPF.this child window should open
I have created a wpf application into which I have added a user control
I have created a wpf vb.net project and am trying to set a simple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.