What version of .NET (64-bit vs. 32-bit) will be loaded if some of the assemblies referenced in an app are compiled with 32-bit only (instead of AnyMachine) setting? Will the app still run as 64-bit or will it be forced to run as 32-bit if at least one of the referenced assemblies is compiled as 32-bit only? The app is running .NET 3.5.
And if the assembly is dynamically loaded, and the process is 64bit, the 32bit assembly will fail to load.
EricLaw -MSFT-
2010-05-01 17:38:50
And if the referenced assembly is compiled as AnyCPU but making use of an unmanaged DLL, then it will fail to run if you don't provide a 64bit version of the unmanaged DLL
Gregory Pakosz
2010-05-01 17:40:33
Isn't the bit-ness of the process determined by the main executable, and if that module references assemblies of a different bit-ness, those will fail to load, not force the process to a different bit-ness? For instance, if you create a executable and compile it for AnyCPU, but it references a bunch of 32-bit assemblies, the process will run fine on a 32-bit OS, but fail to load the additional assemblies on a 64-bit OS?
Lasse V. Karlsen
2010-05-01 18:15:22
+2
A:
The bit-ness is determined by the Platform Target setting on the EXE. There is no mechanism to ensure that a EXE that references a 32-bit only assembly will be forced to run in 32-bit mode as well. The assembly will simply fail to load with a BadImageFormatException.
If your program has a dependency on such a DLL then you must force the Platform Target on your EXE project from AnyCPU to x86.
Hans Passant
2010-05-01 17:54:40