下面是代码示例
var startInfo = new ProcessStartInfo
{
Arguments = commandStr,
FileName = @"C:\Windows\SysWOW64\logman.exe",
};
using (var createCounterProc = new Process { StartInfo = startInfo })
{
createCounterProc.Start();
createCounterProc.WaitForExit();
}运行代码后,我得到“32位进程无法访问64位进程的模块”。MainModule中的消息(NativeErrorCode:299)。我的解决方案被配置为AnyCPU。我尝试过64位和32位版本的logman.exe (C:\Windows\SysWOW64\logman.exe和C:\Windows\System32\logman.exe),但仍然有相同的错误。我的操作系统是Win8.1Prox64。是什么导致了这个问题?
堆栈跟踪:
在System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId,布尔( firstModuleOnly)在System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId) ( System.Diagnostics.Process.get_MainModule()
以下是构建配置:

发布于 2015-12-03 16:28:32
为平台目标选择任何CPU是不够的,您还必须取消选中首选32位,否则应用程序仍将作为32位应用程序运行。

这只能在应用程序项目上实现,而在库项目上是不可能的。如果您的项目是一个库,则必须使用您的库在项目中执行它。
发布于 2015-12-03 17:21:50
经过调查,我意识到Logman.exe是非托管代码,因此它不能以MainModule的形式返回.NET对象,因此它是一种正常的行为。对于Win32Exception,我不会稍微混淆错误信息。它不影响Process.Start()的执行。
https://stackoverflow.com/questions/34070969
复制相似问题