It is completely valid for an AnyCPU
assembly to target an x64 DLL. But, it is up to you to ensure that your AnyCPU
assembly is actually executing as an x64 process.
Note that later versions of Visual Studio have added the "Prefer 32-bit" option to assemblies. So you need to make sure this is turned off, and that you aren't using any settings on the machine that would override that setting.
Also note that if your AnyCPU
assembly references other assemblies that may be available only as x86 assemblies on the target machine, it will be run as an x86 process.
Frankly, if you know that you want the process to only ever run as x64, IMHO it makes the most sense to compile it as x64
. At least that way, if you do wind up running it in an incompatible environment, you'll get a better error message (i.e. the event log will contain the information about the dependency that was incompatible with your process, instead of some other dependency that is actually as expected).