I am working with a client's WinForms application to wrap it up as a Web Service - this is not ideal, but the only choice I have for the moment.
The WinForms app can be called via the command line with some parameters that enable it to generate some output files that I can then process and return the user. This command line interface basically launches the GUI, pre-populates some input fields (provided via command line params), generates the output files, and exits.
From my web service I am using Process.Start() to run the application, wait for it to exit, and then process the output files to return back to the client. (Although the GUI shows itself on the server, I am not expecting any user to see this).
When running in debug mode (Visual Studio 2017) using IIS Express, the code works as expected - I make the appropriate call to the web service, the WinForms application starts-up (I can see it on the screen) and does it thing, it then closes automatically, and the expected output files are found in the expected place. Basically, it all runs exactly as designed.
However, when I deploy to the same server but host under IIS (rather than IIS Express), it no longer works. When I make a call to the web service, I can see, in Task Manager, the WinForms app starting up... however it stalls immediately the UI itself does not show up. After this the memory associated with the WinForms app stays the same (at a level much lower than it is when working properly), and the API call eventually times-out.
I have changed the AppPool in IIS to use my Admin account, and all folders associated with the WinForms app have "Full Control" permission for that same Admin Account. When the WinForms app starts-up it is also associated with the same Admin account (which is also the same as the one IIS Express uses).
Could it be some thing like IIS not having the permissions to start-up an app with a GUI, but IIS Express does?
I've searched SO for similar issues, but none help with this problem (most deal with the usual folder access permissions that can arise when accessing files not under the Web Service's root directory).
The web service is being hosted on Windows Server 2016 Datacenter.
EDIT
I've made a little progress - as per one of the answers at IIS7 does not start my Exe file by Process Start but it's running in task bar I changed the app pool settings to Load User Profile = True (https://i.stack.imgur.com/2pIyr.png). Now when I try, I can see the WinForms app in Task Manager, the memory changes similar to what I'd expect, and the app seems to exit. The GUI does not show up, the expected output files are not created, and the web service process.WaitForExit() does not seem to receive the exit event (it throw an error because of the process instance is lost when the WinForms apps exits).
EDIT
Just a clarification that this is for a demo so the solution needn't reflect best practice for production.