Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine Loaded Assemblies

How can I determine all of the assemblies that my .NET desktop application has loaded? I'd like to put them in the about box so I can query customers over the phone to determine what version of XYZ they have on their PC.

It would be nice to see both managed and unmanaged assemblies. I realize the list will get long but I plan to slap an incremental search on it.

like image 215
Nick Avatar asked Aug 21 '08 19:08

Nick


3 Answers

using System;
using System.Reflection;
using System.Windows.Forms;

public class MyAppDomain
{
  public static void Main(string[] args)
  {
    AppDomain ad = AppDomain.CurrentDomain;
    Assembly[] loadedAssemblies = ad.GetAssemblies();

    Console.WriteLine("Here are the assemblies loaded in this appdomain\n");
    foreach(Assembly a in loadedAssemblies)
    {
      Console.WriteLine(a.FullName);
    }
  }
}
like image 185
Greg Hurlman Avatar answered Oct 23 '22 17:10

Greg Hurlman


PowerShell Version:

[System.AppDomain]::CurrentDomain.GetAssemblies()
like image 44
bernd_k Avatar answered Oct 23 '22 17:10

bernd_k


Either that, or System.Reflection.Assembly.GetLoadedModules().

Note that AppDomain.GetAssemblies will only iterate assemblies in the current AppDomain. It's possible for an application to have more than one AppDomain, so that may or may not do what you want.

like image 20
TheSmurf Avatar answered Oct 23 '22 18:10

TheSmurf