Aboutbox with a list of the used Assemblies of an application.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to make a list of all the ProductNames of the Assemblies used by
my application, made in C#/C-Sharp.

Can anyone tell me where I can find a list of the Assemblies, used by the
appilcation.

Regards
Karsten Lundsgaard
 
Karsten ,

AppDomain.CurrentDomain.GetAssemblies() return all the loaded assemblies it
the application domain. Note that the application domain may reference
assemblies that are not loaded yet, thus not in the returned array.

If you want to get the list of all referenced (loaded or not) assemblies you
can do

Aseembly.GetEntryAssembly.GetReferencedAsemblies. This returns array of
AssemblyName objecects that you probably can use of getting the piece of
info you are after. Once you do that for the entry assembly you need to do
it all referenced assemblies as well, which cannot be done without loading
them. You can do that in the current application domain (you cannot unload
them afterwards, though); you can create a special AppDomain for that and
unload it after you finish or if you use .NET 2.0 you can use
Assembly.RelflectionOnly load or Assembly.ReflectionOnlyLoadFrom().

Keep in mind that all I explained is for one application domain. Normaly
applications have only one application domain, however it is possible an
application to spawn more than one domains.
 
On my About Boxes I use a Listview and run the following to show name,
version, from GAC, and location:

foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
ListViewItem item = new ListViewItem(new string[]
{
assembly.GetName().Name,
assembly.GetName().Version.ToString(),
assembly.GlobalAssemblyCache.ToString(),
assembly.Location
}) ;

lvwAssemblies.Items.Add(assembly.ToString(), item);

}
 
That will give list of loaded assemblies. Some of the referenced assemblies
may not be loaded yet.
 
Back
Top