If I have a \"Any CPU\" compiled .NET app, it will run in 64bit mode on a 64bit OS.
But if I, for whatever reason, wants to force this app to run in 32bit mode. (As if i
I got a new solution!
Writing a custom .NET host is a better solution for this question. Because host is native applications, if you compile it as 32/64bit app, the assembly it loads will run on 32/64bit mode.
Don't need to worry about hosting because .NET build processes provide a default host to run .NET applications. In some specialized circumstances, though, it can be useful to explicitly host the .NET runtime.
So, you can prepare two host (C++ app), one build as 32bit app, the other is 64bit. And make a launch (exe or script) that invoke the host which mode you like. The host will load and run your assembly with the same mode as the host.
There is a tutoral about Hosting Core CLR: Write a custom .NET Core host to control the .NET runtime from your native code.
If your assembly is .net framework app, see Hosting the CLR the Right Way.