I build a program in c#, and the target platform is anyCPU. I want it run in X86 mode or X64 mode when I need it.
Asked
Active
Viewed 202 times
-1
-
Have you seen https://stackoverflow.com/questions/985663/is-there-a-way-to-force-an-any-cpu-compiled-app-to-run-in-32bit-mode-on-64bit – Caius Jard Sep 16 '19 at 06:36
-
@CaiusJard Thank you for your help. And now I have a new idea, I should write my answer below my question or write below the post you given? – anchur Sep 20 '20 at 12:56
-
If you want to answer your own question, you are free to do so.. If it's just an idea rather than a working answer to the original problem, then it should be a comment, an edit or a new question – Caius Jard Sep 20 '20 at 13:00
1 Answers
0
Any assembly compiled with AnyCPU runs:
- In 32 bits mode on x32 OS (int is 32 bits).
- In 64 bits mode on x64 OS (int is 64 bits).
It is automatic.
You can use CorFlags.exe to change this behavior.
To force AnyCPU to run in 32 bits mode on 64 bits OS:
corflags /32bit+ application.exe
You can found it from Windows SDK for Windows Server 2008 and .NET Framework.