Posted by Anuraj on Monday, October 6, 2014 Reading time :1 minute
Due to lack of 64 bit version of few COM libararies, we faced a situation to run our AnyCPU application into 32 bit. You can do this either by setting the Platform target or by using the corflags command.
This will cause the compiler to set the 32Bit flag in the CLR header of the corresponding assembly. Every time we run this application no matter on what type of OS it will execute as a 32bit process. But this solution although simple and straight forward was not a viable solution for us since â€“ as mentioned above â€“ we want to have one and only one version of our product. Thus all components of our package have to be compiled with Platform Target set to Any CPU.
From VS 2011 onwards there is new compiler flag available “Prefer 32-bit”, which will help a .NET application compiled to x86 will fail to run on an ARM Windows system, but an “Any CPU 32-bit preferred” application will run successfully. Also, the “Prefer 32-bit” checkbox is only enabled for .NET 4.5+ executable projects.
You can use this solution as part of the build, so that you can switch to x64 in future, developer don’t need to worry about any platforms.
Happy Programming :)