views:

1600

answers:

1

I've got a "diagnostics" page in my ASP.NET application which does things like verify the database connection(s), display the current appSettings and ConnectionStrings, etc. A section of this page displays the Assembly versions of important types used throughout, but I could not figure out how to effectively show the versions of ALL of the loaded assemblies.

What is the most effective way to figure out all currently referenced and/or loaded Assemblies in a .NET application?

Note: I'm not interested in file-based methods, like iterating through *.dll in a particular directory. I am interested in what the application is actually using right now.

+16  A: 

Getting loaded assemblies for the current AppDomain:

var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

Getting the assemblies referenced by another assembly:

var referencedAssemblies = someAssembly.GetReferencedAssemblies();

Note that if assembly A references assembly B and assembly A is loaded, that does not imply that assembly B is also loaded. Assembly B will only be loaded if and when it is needed. For that reason, GetReferencedAssemblies() returns AssemblyName instances rather than Assembly instances.

HTH, Kent

Kent Boogaart
Wow, how did I miss that!? That's exactly it - thanks so much.
Jess Chadwick