I get 'A 32 bit processes cannot access modules of a 64 bit process.' exception invoking Process.Start()

前端 未结 2 1027
清歌不尽
清歌不尽 2021-01-11 20:32

Here is the code sample

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

         


        
相关标签:
2条回答
  • 2021-01-11 21:24

    After investigation I realized that Logman.exe is unmanaged code, so it cannot return a .NET object as MainModule, so it's a normal behavior. I'ts just slightly confusing error message for Win32Exception. It doesn't influence the execution of Process.Start().

    0 讨论(0)
  • 2021-01-11 21:35

    Choosing Any CPU for Platform target is not enough, you also have to uncheck Prefer 32-bit, otherwise the application will still be run as a 32-bit application.

    This is only possible on application projects, not on library project. If your project is a library, you must do it in the project using your library.

    0 讨论(0)
提交回复
热议问题