Tuesday 8 March 2011

.Net 4 Oddities II

I'll post here some additional information to this old post.
Today I finally could put my hands on a Windows 64 bits system (Windows Server 2008 R2). Yes, it sounds odd, but all my home PCs and my work laptop are 32 bits systems.

After installing the .Net 4 runtime, I went to the C:\Windows\Microsoft.Net folder to make sure that I had a v.4 folder there. First unexpected thing was finding 2 folders there: Framework and Framework64. Obviously one contains 32 bits executable files and the other one 64 bits, but why is this necessary?. I did some web searching and this is what I found:

You do need both the 64 and 32 bit versions of the frameworks on your system. There are a lot things you can only do when the app is run as 32bit. For example most activex controls are 32bit, you can not open an access database when running in 64 bits, etc

That well, does not clarify much to me, for example, I don't see that ActiveX controls play any roll in having 2 csc.exe files.

Then, having a look into the C:\Windows\Microsoft.Net\assembly (this is the GAC location for .Net 4) I got another surprise, finding there 3 folders, GAC_32, GAC_64 and GAC_MSIL. My first thought was that 32, 64 folders would contain those assemblies that have been Ngened, but a glance there didn't show any .ni (native image) file, so seeking some more shared knowledge on the net came up with this:
The GAC_MSIL cache contains assemblies that can be run in either 32-bit or 64-bit mode, and are JIT compiled to the required word size as needed.

The 32/64 directories contain assemblies that are specific to either 32-bit or 64-bit mode, either because they contain native code or because they make specific assumptions about the word size.


That makes good sense to me, and one point that helps us to corroborate this is that the mscorlib.dll assembly (that contains some native code for the MethodImplOptions.InternalCall thing) is in the 32 and 64 folders, and not in the MSIL one.

No comments:

Post a Comment