我得到'32位进程无法访问64位进程的模块.' 异常调用Process.Start()

Max*_*Max 10 c# cpu-architecture

这是代码示例

var startInfo = new ProcessStartInfo
{
    Arguments = commandStr,
    FileName = @"C:\Windows\SysWOW64\logman.exe",
};

using (var createCounterProc = new Process { StartInfo = startInfo })
{
    createCounterProc.Start();
    createCounterProc.WaitForExit();
}
Run Code Online (Sandbox Code Playgroud)

运行代码后,我得到"32位进程无法访问64位进程的模块".MainModule中的消息(NativeErrorCode:299).我的解决方案配置为AnyCPU.我已经尝试了64位和32位版本的logman.exe(C:\ Windows\SysWOW64\logman.exe和C:\ Windows\System32\logman.exe)但我仍然有同样的错误.我的操作系统是Win8.1Prox64.什么可能导致问题?

堆栈跟踪:

at System.Diagnostics.NtProcessManager.GetModuleInfos(Int32 processId, Boolean firstModuleOnly)
   at System.Diagnostics.NtProcessManager.GetFirstModuleInfo(Int32 processId)
   at System.Diagnostics.Process.get_MainModule()
Run Code Online (Sandbox Code Playgroud)

以下是Build配置: 在此处输入图像描述

Alb*_*reo 16

选择任何CPU for Platform目标是不够的,您还必须取消选中首选32位,否则应用程序仍将作为32位应用程序运行.

这仅适用于应用程序项目,而不适用于库项目.如果您的项目是库,则必须使用库在项目中执行.