views:

55

answers:

1

Hi all,

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 http://blogs.msdn.com/b/joshwil/archive/2005/05/06/415191.aspx seem to suggest that if you have a header as follows

PE : PE32

ILONLY : 1

32BIT : 0

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

Unfortunately that doesn't appear to be the case on my windows 7 64bit 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?

Has anyone else had this issue? Is it some registry or environment problem that I've yet to stumble upon?

Many Thanks

+1  A: 

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.

Hans Passant
This is a detail I forgot to include. The assembly is an executable.
jmellor
Document how you are sure that it is running in 32-bit mode. And verify that the 64-bit version of .NET is actually installed on your machine.
Hans Passant
I have both C:\Windows\Microsoft.NET\Framework and Framework64. Both have v2.0.50727 v3.0 v3.5 and v4.0.30319. I'm using taskmgr to verify that the assembly is running in 32bit mode (the process name is appended with *32)
jmellor
You've eliminated any remaining guess I could have.
Hans Passant
Thanks for the time and effort though.
jmellor
I've just realised I never posted anything on this. I did eventually find the problem by randomly searching the registry and it would be useful to post it in case someone else has the same problem. It turns out something had set the following registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\Enable64Bit to 0. I haven't been able to find any documentation on this key doing a quick search so far. However, setting it to 1 and restarting appears to solve my problem.
jmellor