title: How to start a WPF application from a web service?
body: <p>a web service is running with IIS.
  When calling the initialize service, some libraries are dynamically loaded in order to start a wpf application.</p>
  
  <p>The code compiles, runs... but the window never shows up. No exception is thrown whatsoever.</p>
  
  <p>Below is the code that is executed to create the WPF application:</p>
  
  <pre><code>public void Start()
  {
   ThreadStart ts = Run;
          Thread t = new Thread(ts);
          t.SetApartmentState(ApartmentState.STA);
          t.Start();
  }
  
  [STAThread]
  public void Run()
  {
   try
          {
           App app = new App();
                  MainWindow w = new MainWindow();
                  w.Show();
                  app.Run(w);
          } catch (Exception e)
          {
           LogManager.GetLogger("general").Debug(e.StackTrace);
          }
  }
  </code></pre>
  
  <p>If I run that in a console application, it works perfectly:</p>
  
  <pre><code>   static void Main(string[] args)
     {
         MyApplication app = new MyApplication();
         app.Start();
         Console.ReadKey();
     }
  </code></pre>
  
  <p>But if I run it from the web service, code is correctly executed (as I can debug it, and no exceptions) but the window never shows up:</p>
  
  <pre><code>public void initialize() {
   IMyApplication application = assembly.CreateInstance(namespaceValue + ".MyApplication") as IMyApplication;
          application.Start();
  }
  </code></pre>
  
  <p>I can see in the process manager that the WPF process is running... Any idea why the window does not show up ?</p>
  
  <p>Regards,</p>
  
  <p>Francois</p>
  
  <hr>
  
  <p>Is there something special to do to grant all access/rigths to the web service ?</p>