vb.net 错误“来源:系统进程已退出,因此请求的信息不可用”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14576848/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error "Source: system process has exited, so the requested information is not available"
提问by C PWL
It's works in my PC but when i put into another machine i got an error "source: system process has exited, so the requested information is not available" & the exe doesnt came out. Any experienced bro can help? Appreciated!
它可以在我的 PC 上运行,但是当我放入另一台机器时,出现错误“源:系统进程已退出,因此请求的信息不可用”并且 exe 没有出现。有经验的兄弟可以帮忙吗?赞赏!
p = New Process
With p
.EnableRaisingEvents = True
.StartInfo.FileName = Application.StartupPath & "\EXE\CDMObjectSelection\CDMObjectSelection.exe"
.StartInfo.Arguments = strArgs
.StartInfo.ErrorDialog = True
.StartInfo.WindowStyle = ProcessWindowStyle.Normal
.StartInfo.UseShellExecute = True
.Start()
End With
p.WaitForInputIdle()
While (ginthwnd = IntPtr.Zero)
System.Threading.Thread.Sleep(100)
p.Refresh()
ginthwnd = p.MainWindowHandle
End While
回答by culix
If you follow this code in a debugger or wrap it in a try/catchblock you'll probably find that the exception happens on the line p.WaitForInputIdle(). As MSDN states: this exception is thrown when the process has already exited. Try wrapping your call in a try/catchand dealing with the InvalidOperationException.
如果您在调试器中遵循此代码或将其包装在一个try/catch块中,您可能会发现异常发生在行上p.WaitForInputIdle()。正如MSDN 所说:当进程已经退出时会抛出这个异常。尝试将您的呼叫包装在 a 中try/catch并处理InvalidOperationException.
MSDN also says "If a process does not have a message loop, WaitForInputIdle throws an InvalidOperationException". Make sure the process you're calling has a message loop.
MSDN 还说“如果进程没有消息循环,WaitForInputIdle 将抛出 InvalidOperationException”。确保您正在调用的进程具有消息循环。
See this answerfor how to properly shut down your process.

