Search code examples
c#gac

How to find or use a custom library from the GAC


I'm using Windows 8 and I'm trying some things with the Global Assembly Cache (GAC). I created a simple library called AAA, I added a sn key for this in my VisualStudio project, and built it. Later gacutil -i AAA.dll was run. The result message was that the library is successfully installed in the GAC.

I'm also able to do: gacutil -l AAA, it returns some information about the library.

But I'm wondering:

  1. How to find the GAC instance file or any GAC reference for my AAA library. I looked in C:\Windows\Assembly, but I was not able to find the file.

  2. How to use GAC library? I was not able to find AAA dll in the Add-Reference window in Visual Studio, why?


Solution

    1. Since .Net 4 there is "another GAC". It can be found on:

      C:\Windows\Microsoft.NET\assembly

      This folder contains all the .Net 4 (or greater) assemblies that are on the GAC

    2. By default the assemblies on the GAC are not shown on the Add-Reference dialog. You can either browse to the GAC folder or just add the reference to another copy of the same binary you have anywhere else. In runtime the references are looked first on the GAC, and if they are found there it won't look at anywhere else.

    Bear in mind that both the old C:\windows\assembly and the new folder counts as GAC for the runtime so DLLs will be search in both places.