The application and all of its libraries are compiled with Platform AnyCPU and Prefer32Bit off. The application loads its libraries from embedded resources, using the currentDomain.AssemblyResource event.
The application is deployed to over one hundred PCs, running Windows 7, Vista, 10, 2008 and 2012. But on some Windows 7 Enterprise 64-bit PCs (not all of them), when the application loads the embedded class libraries the BadImageFormatException is thrown. The JIT compiler is somehow resolving on those PCs to compile the class library to 32 bit instead of 64 and since the hosting application was compiled to 64 bit the exception is thrown.
What other factors will the JIT compiler use in addition to the ones listed above (OS 64 bit, AnyCPU and Prefer32Bit off) to decide in only a few PCs to select 32 instead of 64 bit when loading the class library?