# Saturday, August 20, 2005
« AppDomain.Unload() and CannotUnloadAppDo... | Main | The Wonders of the Whidbey GAC -- Part I... »

The GAC -- Global Assembly Cache -- is a popular topic among managed code developers. It serves two main purposes: (A) as a catalogue of the globally publicly available assemblies available on the system, indexed by strong name, and (B) the location of those same files. It is not my intent to describe the GAC, however; look here for more info. My intent is to describe some interesting changes that have been made to the GAC for Whidbey and to promote some good practices. This is part I and is dedicated to processor architecture; we'll see how far we get with the series ;)

Whidbey is the first CLR release in which we support 64-bit execution. The CLR team has been working on porting the CLR to 64-bit for several years now and is now releasing it to the world with Whidbey. Woohoo! Not surprisingly, 64-bit has required a lot of changes all over the CLR, as it imports a bunch of new concepts onto us. My favourite is the general concept of processor architecture, of which there are four that we now support: X86, X64, IA64 and MSIL. We always supported the first and the last, but there was never a strong reason to differentiate them considerably as we only ran on a 32-bit system.

With respect to the v1.x GAC (v1.0 and Everett share the same GAC), you can see pretty clearly that processor architecture was not a design point.

V1.x GAC location
C:\Windows\assembly\GAC

V1.x System.dll location
C:\WINDOWS\assembly\GAC\System\1.0.5000.0__b77a5c561934e089\System.dll

Where would you have tagged the processor architecture? Nowhere that I can see. As a result, we changed the GAC structure in Whidbey to accommodate processor architecture, which is now an incredible important aspect of the GAC.

V2.0 GAC locations on an x86 machine
C:\Windows\assembly\GAC_MSIL
C:\Windows\assembly\GAC_32

V2.0 System.dll and mscorlib.dll locations on an x86 machine
C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll

V2.0 GAC locations on an x64 or IA64 machine
C:\Windows\assembly\GAC_MSIL
C:\Windows\assembly\GAC_32
C:\Windows\assembly\GAC_64

V2.0 System.dll and mscorlib.dll locations on an x64 machine
C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll
C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll
C:\WINDOWS\assembly\GAC_64\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll

You can now see that it is easy to tag assemblies with processor architecture. We’ve created three GACs to do just that! As you can see, the GAC_64 directory only shows up on 64-bit machines, which is hopefully quite intuitive.

I’ve run out of time to get any further in this post, but hopefully it gives you a good idea of how and why the GAC changed, at least with respect to processor architecture in Whidbey. I also hope I left you with the opinion that these changes were a good idea ;)

A question to ponder: If you call System.Reflection.Assembly.Load(“System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”) and there is both a copy in the bit-specific GAC and another in the bit-agnostic (MSIL) GAC, which do you get?

Saturday, August 20, 2005 10:05:57 PM (GMT Daylight Time, UTC+01:00)
My guess is that it is first going to try and load the version that fits the processor architecture first. So if it's a 64 bit machine it will first look in the x64 bit directory. If it doesn't exist there I would expect it to look in the MSIL directory.

This of course leads me to ponder, so it's possible to have the same assembly have completely different behaviors depending on the architecture. This isn't that suprising, however I could see this as another gotcha for troubleshooting cross platform applications.
Thursday, September 08, 2005 1:05:07 PM (GMT Daylight Time, UTC+01:00)
Hello!I found here a plenty of useful information for myself! I will visit you soon...
Friday, September 09, 2005 9:03:13 AM (GMT Daylight Time, UTC+01:00)
The interesting information located on your page
Friday, September 23, 2005 9:20:59 AM (GMT Daylight Time, UTC+01:00)
Hello. I just wanted to give a quick greeting and tell you I enjoyed reading your material
Tuesday, January 31, 2006 8:35:01 PM (GMT Standard Time, UTC+00:00)
This is actually a good question. On my machine i ran into an error with a control that is written both to GAC and GAC_MSIL and the compiler is confused as to which version to use....

Error 21 The type 'Infragistics.WebUI.Shared.BorderDetails' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\Infragistics2.WebUI.Shared.v5.3\5.3.20053.73__7dd5c3163f2cd0cb\Infragistics2.WebUI.Shared.v5.3.dll' and 'c:\WINDOWS\assembly\GAC\Infragistics.WebUI.Shared.v5.2\5.2.20052.27__7dd5c3163f2cd0cb\Infragistics.WebUI.Shared.v5.2.dll' c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\purchasingportal\78e2c7b0\529b52c6\App_Web_ot_dtpdv.12.cs 2160
Prashant Sheth
Comments are closed.