ProcessManager引发没有足够的内存资源可用于处理此命令

巴布

新成员
已加入
2020年6月16日
留言内容
3
编程经验
1-3
球队,

NtProcessManager,ProcessManager抛出以下错误
没有足够的内存资源可用于处理此命令
引发了System.OutOfMemoryException类型的异常。

并知道它是从ProcessManager抛出的。 System.Diagnostics.Process.cs。请让我知道为什么我会出错,以及如何优化代码

获取具有窗口的进程:
                IEnumerable<Process> processes = Process.GetProcesses()
                          .Where(p => (long)p.MainWindowHandle != 0
                                    && p.MainWindowTitle.Length > 0
                                    && (p.StartInfo.WindowStyle == ProcessWindowStyle.Maximized
                                            || p.StartInfo.WindowStyle == ProcessWindowStyle.Normal)
                                     );
 

金西尼

C#论坛主持人
工作人员
已加入
2011年4月23日
留言内容
3,481
位置
悉尼,澳大利亚
编程经验
10+
Whenever you have a complex operation like that that fails, the way to diagnose it is to break it down into parts and see which part it fails on. That's what you need to do. I suspect that it has to do with the fact that you're trying to examine the StartInfo of processes that you didn't start. That can't do anything useful and, it may fail outright. The StartIfo property of a Process object is only relevant if you created that Process yourself by starting a process. You can't get the that information from running processes.
 
最佳 底部