My computer runs Windows 7 X64 Enterprise Edition. I need x86 mode for my executable as I use Visual Foxpro OLEDB driver. I thought it was required to compile library DLLs which are used by this exe as "X86". However, DLLs compiled with "Any CPU"seem to work which is quite convenient as they are used somewhere else and no need to maintain 2 copies. Just wondering how it works and should I continue like this ?
views:
92answers:
3
+2
Q:
Windows x64 C# x86 console application exe seems to work with "DLL any CPU" Any potential problem ?
+2
A:
This is fine. As long as the executable is compiled targetting x86, any "Any CPU" targeted assembly will get loaded as x86.
You just can't load an assembly explicitly targeting x64, as that won't work in a 32bit application.
Reed Copsey
2010-07-21 00:45:09
+1
A:
The decision is made when your .exe is loaded. The 32BIT flag in the assembly metadata header will determine whether the 32-bit or the 64-bit of the CLR is loaded. And, most significantly, the x86 or the x64 JIT compiler. After that, the JIT compiler generates the proper flavor of machine code, regardless of the bitness of any of the DLLs that are loaded afterward.
Thus, only the target platform setting for the EXE matters.
Hans Passant
2010-07-21 01:08:28