I’d like to be able to distribute one version of an executable that a user can configure to run as either 32-bit or 64-bit. The service would have a 32-bit host process that would read configuration and launch new processes as 32 or 64-bit. What I haven’t determined is how/if a executable targeted for Any CPU can be launched as a 32-bit process under 64-bit Windows.
Share
This makes little sense. If your app can run as a 32-bit process and doesn’t need the extra virtual memory space then there’s just no point in ever running it as a 64-bit process.
Nor can you easily control it. It requires changing a value in the .exe header. The Corflags.exe utility can do this, but you cannot distribute it. Hacking the headers yourself is technically possible but very fugly. The ultimate obstacle is that you don’t typically have the write access that’s required to modify the .exe file on a properly secured machine (ie UAC). If you really, really need to do this then just deploy two copies of the .exe
Which you can do by writing a very puny bootstrapper .exe. All it needs to do is Assembly.Load() the main .exe and call its Program.Main() method. Build two versions of it.