views:

59

answers:

2

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

+1  A: 

Check your application pool and tell me what user it uses - or if you use impersonation.

My first guess would be that this runs as a service user (with no rights to mess with a desktop and especially not with your desktop). In general I think this is a strange thing to do..

Why don't you use a Silverlight out of browser application? Why no ClickOnce?

Benjamin Podszun
hummm, I am not a specialit of SII...But I can see in the administration configuration tool that the web service is using Application Protection : Medium (Pooled)Does it answer the question ?
Francois
In the Web.config file, I have this : <Authentification mode="Windows">
Francois
Actually, the idea is to build on top the web service a desktop application to manage the business model locally on the same machine. So in order to share the objects in memory, the web service must instanciate the application and pass over the business model to it. For performance issue I do not want to communicate to the web service locally.
Francois
A: 

Is there something special to do to grant all access/rigths to the web service ?

Francois