Is it possible to force a C# application compiled with the “Any” architecture tag to run as a 32 bit application on 64 bit windows?

Solution 1:

Yes, if you set the project properties to use 32-bit (x86 I think) explicitly it will always run in that mode. We had that issue when using the SQLite ADO.Net provider (it was looking for the 32-bit version only, which couldn't load when run on a x64 system).

You can use corflags to set the 32-bit bit (ha ha) flag on the executable. Here is an example. In short, you'll run:

corflags /32BIT+ assembly.exe-or.dll

You'll find corflags.exe installed with the SDK with Visual Studio (installed in C:\Program Files\Microsoft SDK\6.0a or 7.0\bin) or you can get it from the the Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1.