安装程序错误:进程必须退出1001



有人知道这个错误消息来自哪里吗:

"进程必须在请求信息之前退出"1001

当我的客户端运行我的安装程序(Visual Studio 2010中的安装项目)时,我会遇到此错误,因此我的程序永远不会安装。我怀疑这是因为在我的自定义安装程序操作中使用了以下代码:

System.Diagnostics.ProcessStartInfo

有人能证实或否认吗?有人能告诉我这到底意味着什么吗?


EDIT-用于调用进程的代码。

//Invoke the process.
Process Process = Process.Start(ProcessInfo);
Process.WaitForExit(Timeout);
//Finish.
int ExitCode = Process.ExitCode;
Process.Close();
return ExitCode;

如果我查看"检查正在运行的进程",那么抛出带有信息process must exit before requested informationSystem.InvalidOperationException的函数只有ExitCodeExitTime,所以你可能使用了Process类的这些函数来查找正在运行的过程的信息,并以错误的方式使用了这两个函数中的任何一个
更有可能你有这个代码,

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

在访问ExitCodeExitTime功能之前,请使用WaitForExitHasExited,例如

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在MSDN文档中,还清楚地提到了它的章节标题注意

Kill方法异步执行。在呼唤杀戮之后方法,调用WaitForExit方法等待进程退出,或检查HasExited属性以确定进程是否已退出。

编辑查看代码后,

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;

最新更新