Windows CAN NOT load a 32bit dll into a 64bit process - this is a limitation that you can not circumvent. This means that if your 32bit DLL does any P/Invokes to other 32bit DLLS (or uses any 32bit .Net DLLS) you will be entirely out of luck (you will need to run the entire website in 32bit).
You are not entirely clear on when it works and when it doesn't. Here are the explanations:
- x86 - 32bit - Can not be loaded into a 64bit process.
- x64 - 64bit - Can not be executed on a 32bit machine.
- AnyCPU - dual - Can be loaded and executed in both environments.
In terms of AnyCPU:
- 64bit process on 64bit machine - DLL is loaded as 64bit.
- 32bit process on 32bit machine - DLL is loaded as 32bit.
- 32bit process on 64bit machine - DLL is loaded as 32bit.
In most cases it's fine to leave it as AnyCPU. However, as I said, if you are using any native or .Net 32bit DLLs you will need to make your entire application 32bit (and there is nothing you can, or Microsoft could, do about this).