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

  • SEARCH
  • Home
  • 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 132963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T06:20:46+00:00 2026-05-11T06:20:46+00:00

I found some rather strange behavior… Here is how to replicate the problem: Create

  • 0

I found some rather strange behavior…

Here is how to replicate the problem:

  1. Create a WPF Application Project.
  2. Remove the StartupUri from the App.xaml file.
  3. Add a Startup Event Handler to the App with signature ‘private void Application_Startup(object sender, StartupEventArgs e)‘
  4. Now, add a Form to the project (right click and select add new item).
  5. in the Application_Startup method, create the form object and show it like Form1 f1 = new Form1(); f1.ShowDialog();
  6. On the actual Form1, add a button to the designer, and add a click event handler to the button.
  7. Add a new WPF window to your project, Window1.
  8. In the Form1’s button click event handler created in step 6, add the lines of code to create display the WPF window: Window1 w1 = new Window1(); w1.Show();
  9. Run the project and click the button on the winform to show the WPF window… works fine so far.
    1. Close the WPF window and click the winform’s button again. This time you should get the exception.

So, essentially what I do is create a WPF application that displays a winform. Then, the winform displays a WPF Window.

The first time the WPF window is displayed, everything works fine. If it is closed, and then re-opened, I get the exception! I can also open up multiple WPF windows by clicking the button multiple times. Once the last one is closed, however, I can never open another one again without the exception…

I have also tried the various tips suggested at http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/442782b1-00a1-4e2e-9cc6-ae99b6699126/ but those don’t help.

Why is this happening?

  • 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. 2026-05-11T06:20:46+00:00Added an answer on May 11, 2026 at 6:20 am

    The default Wpf applicationshutdown behavior (specified on the ‘Application’ tab in project properties in VS or using the ShutdownMode attribute in Application.Xaml) is ‘On Last Window Close’. This means that when you close the Wpf window you create, Wpf shuts down the application framework so any subsequent window creations will throw an exception.

    You can avoid this problem by setting the Shutdown mode to ‘On explicit shutdown’ (‘OnExplicitShutdown’ in Xaml). You will then need to manually call Application.Current.Shutdown explicitly when you want the app to terminate (e.g. when the winforms form is closed).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 98k
  • Answers 98k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What you want is called a "point sprite." OpenGL1.4 supports… May 11, 2026 at 7:30 pm
  • Editorial Team
    Editorial Team added an answer Depends on which client you're using. As far as I… May 11, 2026 at 7:30 pm
  • Editorial Team
    Editorial Team added an answer This could be just a work-around or gremlins ...or the… May 11, 2026 at 7:30 pm

Related Questions

I found some rather strange behavior... Here is how to replicate the problem: Create
after doing some test-code for this link : Is it safe to call temporary
I'd like to learn how to effectively use Swing Application Framework . Most of
For my apps, I store some configuration file in xml along with the assembly(exe),
I'm working on a sheet that accesses a legacy data source via MS Query.

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.