简体   繁体   中英

Process.Start() issue - No GUI displayed

I'm trying to launch a WPF .exe from my VisualWebGUI (winforms on the web basically) application. Everything works fine when I run it through VS2010. However when I deploy the site to IIS it does launch the .exe (I can see it writing out to a log file) but it does not show me the GUI of the WPF app. I can see the process running in Task Manager too! Very simple stuff really, just passing one arguement:

Process p = new Process();
p.StartInfo.FileName = Security.ExePath
p.StartInfo.Arguments = ID
p.Start();

I've tried fiddling around with the different startinfo parameters but to no avail, am I missing something?

That's may because the application is started under the AppPool identity (eg ApplicationPoolIdentity). Try to set the Identity under "Advanced Settings" for the AppPool to the User that is logged in and should see the application.

You will need to specify proper window station for your process, in order for it to get access to the same UI as your current Windows logon session.

Look here: http://support.microsoft.com/kb/165194 and read on about Windows API, for example here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms682429(v=vs.85).aspx

As a side note, launching GUI from a worker process is a really bad idea - primarily because you never guarantee that there IS any interactive user at any point in time. When you use IIS, your primary assumption must be that there is nobody looking at the server screen.

You'll be better off having your GUI application (or a lightweight stub) automatically started up when user logs on, and then listening for signals from the background process.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM