.Net: Assemblies (Part – 3)

We have created hello.exe assembly in our previous article and installed it into Global Assembly Cache (GAC). Lets look at where in GAC this assembly installed.

As we discussed in our previous article(s), GAC is the location where shared assemblies will be placed. Where this GAC located? For .Net version prior to version 4.0, runtime use, C:\Windows\assembly as the GAC. From version 4.0, it is C:\Windows\Microsoft.NET\assembly.

Lets open GAC, and see what it contains. At command prompt type the following command to goto GAC.

cd c:\Windows\Microsoft.NET\assembly

If .NET version 4.0 or higher installed, type the above command. Otherwise, type the below command:

cd c:\Windows\assembly

Usually these folders contains the following structure:

+ GAC_32
+ GAC_64
+ NativeImages_vx.x.xxxxx_32
+ NativeImages_vx.x.xxxxx_64
  • GAC folder is for backward compatibility with older versions of .Net (1.0 and 1.1).
  • GAC_32 and GAC_64 folders are for assemblies for 32-bit and 64-bit platforms respectively.
  • GAC_MSIL folder contains the assemblies which are developed with pure .Net code.
  • NativeImages_vx.x.xxxxx_32 and NativeImages_vx.x.xxxxx_64 folders contains assemblies compiled to native code for 32-bit and 64-bit platforms. Where vx.x.xxxxx is the run-time version number.

Lets check in GAC where our hello.exe file exists. Type the following command at command prompt.

gacutil /l hello

This command will list the assembly information. It returns:

c:\Visual Studio Projects 2012>gacutil /l hello
Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.30319.17929
Copyright (c) Microsoft Corporation. All rights reserved.

The Global Assembly Cache contains the following assemblies:
hello, Version=, Culture=neutral, PublicKeyToken=f5d51cce1ddbf0b7, proc

Number of items = 1

Observe the result that, GAC contains hello assembly of version= We have installed .Net 4.x in our system. So, our hello assembly would be in “c:\Windows\Microsoft.NET\assembly” folder. Open this folder in command prompt. As we developed our hello assembly using pure .Net code; so, our assembly must be in GAC_MSIL folder. Open GAC_MSIL folder and check for hello folder. Once you find open hello folder, you will find the below folder structure.

- hello
  - v4.0_0.0.0.0__f5d51cce1ddbf0b7
    . hello.exe

hello.exe found in “GAC_MSIL\hello\v4.0_0.0.0.0__f5d51cce1ddbf0b7” folder. This is the place gacutil installed our assembly into GAC.

Lets closely look at folder name “v4.0_0.0.0.0__f5d51cce1ddbf0b7”.

  • v4.0 is the .Net run-time version we used to create the assembly.
  • is our hello assembly’s version number. Because we are not set any version number to our assembly. So, its showing as our assembly’s version.
  • f5d51cce1ddbf0b7 is the publickey token. Do you remember we have generated a key pair and added it to our assembly? This is the publickey token we generated using Strong Name Tool (sn.exe).

But why it generates folder structure under hello assembly? This is one of the advantage of an assembly. Assemblies support multiple versions and we can deploy multiple versions side-by-side. Each assembly will store into respective version based folder. Because of this it eliminates versioning problems, we normally face with normal DLLs.

We will discuss about assembly versioning into our next article.

1 comment for “.Net: Assemblies (Part – 3)

Leave a Reply