Reputation:
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?
Upvotes: 0
Views: 2663
Reputation: 62246
I would go for fixed path, cause it can be subject of change, but insted for or use
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
Upvotes: 0
Reputation: 17631
Either access the global assembly cache with the gacutil or use a wrapper like introduced on this msdn page.
Upvotes: 0
Reputation: 223247
//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
Upvotes: 4