Understanding an assembly header with CorFlags (why my assembly loads in 32-bit address space?)

1.3k views Asked by At

I've found a fair bit of information related to how a .NET assembly should load based on the flags set in the assembly header. Pages such as Flipping bits on managed images to make them load with the right bitness... seem to suggest that if you have a header as follows.

PE : PE32 

ILONLY : 1

32BIT : 0 

It has been compiled as "Any CPU", and I can expect it to load with the 32-bit CLR on 32-bit platforms and with the 64-bit CLR on 64-bit platforms. This is exactly the behaviour I expected and wanted.

Unfortunately that doesn't appear to be the case on my Windows 7 64-bit machine. The assembly loads up in a 32-bit address space. I know I should be able to force the issue at compile time by building with x64, but why is it doing the wrong thing in the first place?

How can I fix this problem? Is it some registry or environment problem that I've yet to stumble upon?

1

There are 1 answers

6
Hans Passant On

You didn't say anything about the kind of assembly. Only the startup assembly determines the bit-ness of the process. The EXE. Any DLL must follow suit.