0

To add a new .NET reference to your project in Visual Studio you just click "Add reference..." on References of the current project, switch to the ".NET" tab and go for it.

Now, is there a way to get this list programmatically?

Jodrell
  • 34,946
  • 5
  • 87
  • 124

3 Answers3

4

//You need to access GAC

List<string> gacFolders = new List<string>() { 
    "GAC", "GAC_32", "GAC_64", "GAC_MSIL", 
    "NativeImages_v2.0.50727_32", 
    "NativeImages_v2.0.50727_64" 
};

foreach (string folder in gacFolders)
{
    string path = Path.Combine(@"c:\windows\assembly", folder);
    if(Directory.Exists(path))
    {
        Response.Write("<hr/>" + folder + "<hr/>");

        string[] assemblyFolders = Directory.GetDirectories(path);
        foreach (string assemblyFolder in assemblyFolders)
        {
            Response.Write(assemblyFolder + "<br/>");
        }
    }
}

Source: enumerating assemblies in GAC

Community
  • 1
  • 1
Habib
  • 219,104
  • 29
  • 407
  • 436
0

Either access the global assembly cache with the gacutil or use a wrapper like introduced on this msdn page.

Matten
  • 17,365
  • 2
  • 42
  • 64
0

I would go for fixed path, cause it can be subject of change, but insted for or use

GacUtil

example, from command line can use

gacutil /l > assemblylist.txt 

and assemblylist.txt will have a list of all assemblies in GAC with all information you need.


or can try to use

GAC Api (not documented one) You will need to do some interop on this, it's not C#.

Can try to use this C# warpper for it

GAC API Interface

Tigran
  • 61,654
  • 8
  • 86
  • 123