I'm facing a strange problem with the IIS Local. I've developed a webapi Controller that, at some point, opens Excel, makes some processing with macros and then closes. Here's the piece of code that opens Excel with several parameters:
var procStartInfo = new ProcessStartInfo(
this.Parameters[ConsoleExecutionParameters.FileToExecute],
this.ParametersProcessed)
{
CreateNoWindow = false,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
RedirectStandardInput = true,
WindowStyle = ProcessWindowStyle.Maximized,
WorkingDirectory = workingDirectory
};
using (var proc = new Process { StartInfo = procStartInfo })
{
try
{
proc.EnableRaisingEvents = true;
proc.Start();
proc.WaitForExit(60000);
proc.StandardInput.Flush();
if (!proc.HasExited)
....
Gotta say that this piece of code WORKS (and opens the excel correctly) if the WebAPI is run under IIS Express. However, when running it under a local IIS, an Excel process is opened (at least it is shown in the task manager) but no Excel window appears, the application seems to hang when "proc.WaitForExit" instruction is called, and EXCEL.EXE process stays like in a "zombie" state. After some time (60 seconds) my application times out and the Excel.EXE process is still hung.
Does someone have any idea about why it works on IIS express and doesn't in Local IIS?
Thanks and kind regards.