title: Multiple calls of Application.Run in WPF
body: <p>I'm trying to run a window, close it, and then run a second window, in a similar way that seems to work with Windows Forms.</p>
  
  <pre><code>namespace WpfApplication1
  {
  
  public partial class App : Application
  {
      [STAThread]
      public static void Main()
      {
          Application app = new Application();
          //windowMain.Show();
          app.ShutdownMode = ShutdownMode.OnExplicitShutdown;
          MainWindow windowMain = new MainWindow();
          app.Run(windowMain);
          Window1 window1 = new Window1();
          window1.Show();
          app.Run(window1);
      }
  }
  }
  </code></pre>
  
  <p>I've set the Build Action in the App.xaml properties from ApplicationDefinition to Page, but the programme throws an exception when window1 is initialised. What am I doing wrong?</p>
  
  <p>Edit: I've modified the xaml in App.xaml as suggested by first answer and edited main as suggested by the comment.</p>
  
  <pre><code>&lt;Application x:Class="WpfApplication1.App"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  StartupUri="MainWindow.xaml"
  ShutdownMode="OnExplicitShutdown"&gt;
  &lt;Application.Resources&gt;
  &lt;/Application.Resources&gt;
  &lt;/Application&gt;
  </code></pre>
  
  <p>but I'm still getting the exception.</p>