I am working on a tool that loads different assemblies using System.Reflection
's method Assembly.Load
Here is what i get
On a 64bit OS, if application configured with :
- x64 loads x64 & AnyCPU Assembly
- x86 loads x86 & AnyCPU Assembly
- AnyCPU loads x64 & AnyCPU Assembly
Now when it's configured with AnyCPU Prefer 32 bit on 64 bit OS,it will be running on 32bit process as it said here
In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, “Any CPU 32-bit preferred”, which is the new default (overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu32bitpreferred). When using the "Prefer 32-Bit" flavor of AnyCPU, the semantics are as follows:
- If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
- If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
- If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.
The difference, then, between “Any CPU 32-bit preferred” and “x86” is only this: 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.
My Question is : Why it loads x64 assembly without any problem? isn't that a strange behaviour?
I have seen this question ODP.NET x64 ANYCPU and Prefer 32-bit setting that support this proposition