Question

Does anybody know where this error message is derived from:

"process must exit before requested information" 1001

I am getting this error when my client is running my setup program (the Setup Project you get with Visual Studio 2010), my program as a result, never installs. I suspect it is from using this code in my custom installer action:

System.Diagnostics.ProcessStartInfo

Can anyone confirm or deny - and can anyone tell me what it actually means?


EDIT - code used to invoke process.

//Invoke the process.
Process Process = Process.Start(ProcessInfo);
Process.WaitForExit(Timeout);

//Finish.
int ExitCode = Process.ExitCode;
Process.Close();
return ExitCode;
Was it helpful?

Solution

If I look at Examine Running process the only functions which throw System.InvalidOperationException with information process must exit before requested information are ExitCode and ExitTime so you might have used these function of Process class to find the information of running process and used any of the two functions in wrong way.
More probably you have this code,

Process p = ... Your way to find a process;//
p.Kill();
int exitCode = p.ExitCode; // Or you have ExitTime used

Please use WaitForExit or HasExited before accessing the ExitCode or ExitTime function something like,

Process p = ... Your way to find a process;//
p.Kill();
while(!p.HasExited)
{ 
    p.WaitForExit(60000); //Wait for one minute 
}
int exitCode = p.ExitCode; // Or you have ExitTime used

EDIT In MSDN documentation it is also clearly mentioned with section heading Note that,

The Kill method executes asynchronously. After calling the Kill method, call the WaitForExit method to wait for the process to exit, or check the HasExited property to determine if the process has exited.

EDIT After looking at your code do this,

Process Process = Process.Start(ProcessInfo);
while(!Process.HasExited)
   Process.WaitForExit(Timeout);

//Finish.
int ExitCode = Process.ExitCode;
//Process.Close(); NO NEED AS PROCESS IS ALREADY EXITED
return ExitCode;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top