Hello all,
a web service is running with IIS. When calling the initialize service, some libraries are dynamically loaded in order to start a wpf application.
The code compiles, runs... but the window never shows up. No exception is thrown whatsoever.
Below is the code that is executed to create the WPF application:
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);
}
}
If I run that in a console application, it works perfectly:
static void Main(string[] args)
{
MyApplication app = new MyApplication();
app.Start();
Console.ReadKey();
}
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:
public void initialize() {
IMyApplication application = assembly.CreateInstance(namespaceValue + ".MyApplication") as IMyApplication;
application.Start();
}
I can see in the process manager that the WPF process is running... Any idea why the window does not show up ?
Regards,
Francois