C# System.Diagnostics.Process: can't launch a 32 bit exe file in 64 bit OS

后端 未结 4 2006
梦如初夏
梦如初夏 2021-01-14 06:01

I have a 32 bit exe file compiled with Turbo Pascal. I need to launch it. It worked well when I had Windows 7 32 bit, but now I\'m on Windows 7 64 bit, and I get the followi

4条回答
  •  孤独总比滥情好
    2021-01-14 06:09

    If you're launching the 32 bit exe from within a .NET (C#) application, then you'll need to set the target for your .NET app to x86. If it's set as Any CPU, then it will run as a 64 bit process on a 64 bit OS and therefore won't be able to launch the 32 bit process.

    Edit: This MSDN article explains how to modify this setting: http://msdn.microsoft.com/en-us/library/5b4eyb0k.aspx

    Edit 2: As Gabe points out, there shouldn't be a reason why the 64 bit app could not start a 32 bit exe. I know you can't use a 32-bit DLL from within a 64-bit app. Just thought it would be worth trying since the documentation doesn't specify if that same restriction exists when using System.Diagnostics.Process to launch an exe.

提交回复
热议问题