Getting list of assemblies and their paths

G

Guest

I need to figure out how to get a list of everything in the GAC and a path to
it. I have code that will go through and get a list of the assemblies
through Fusion, however, when I do an Assembly.LoadWithPartialName() the
directory I receive back in "Location" appears to be the actual dll instance
as its been cached/loaded (??). Example, instead of
C:\WINNT\Microsoft.NET\Framework\v1.1.4322\Accessibility.dll, I see,
c:\winnt\assembly\gac\accessibility\1.0.5000.0__b03f5f7f11d50a3a\accessibility.dll.

I'm basically looking to mimic the .NET tab on the Add Reference dialog in
the IDE.

Any clues?

Thanks.
 
M

Mattias Sjögren

I'm basically looking to mimic the .NET tab on the Add Reference dialog in
the IDE.

Any clues?

That has nothing to do with the GAC. VS lists the assemblies in the
framework directory
(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory())
plus additional directories listed in the Registry, as described here

http://support.microsoft.com/?kbid=306149



Mattias
 
G

Guest

Awesome. This is what I was looking for.

Now, this may be a dumb question, but is there any way to tell definitively
that the DLL(s) I encounter in those subdirectories are .net DLLs, or is it a
guarantee that they are?

Thanks again.
 
D

David Levine

You can try loading them using AssemblyName.GetAssemblyName(path). If it
throws an exception it's not a .net DLL. Use this API because it does not
keep the assembly loaded in memory.
You can also parse the PE file headers yourself using unmanaged APIs...I
think this method is a bit easier.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top