Home About

February 24th, 2009

Show all assemblies loaded by your C# program - 3

Sometimes it is handy to have a quick overview of all the assemblies that your C# program has loaded. Maybe because you are trying to debug a version conflict, or because you want to distribute your application and want to get an idea of its dependencies.

To find the loaded assemblies we first need to determine the current AppDomain (it is possible for your application to have more than one AppDomain, but in that case you have created the second one yourself). Each AppDomain keeps a list of Assemblies it is using and in the following example code we query it using the GetAssemblies() method.

By calling FullName we obtain the name, version, culture and public key ID for each assembly.

using System;
using System.Text;
using System.Reflection;

namespace AssemblyListing
    class Program
        static void Main(string[] args)
            AppDomain MyDomain = AppDomain.CurrentDomain;
            Assembly[] AssembliesLoaded = MyDomain.GetAssemblies();

            foreach (Assembly MyAssembly in AssembliesLoaded)
                Console.WriteLine("Loaded: {0}", MyAssembly.FullName);
Be Sociable, Share!

Tags: ,

3 Responses to “Show all assemblies loaded by your C# program”

  1. Gareth Says:

    Yep, this is well useful for debugging version conficts, especially with apps that have a lot of assemblies.

    Assuming you didn’t want to make further use of AppDomain and Assembly[], you could shorten this to:

    foreach (Assembly MyAssembly in AppDomain.CurrentDomain.GetAssemblies())
    Console.WriteLine(“Loaded: {0}”, MyAssembly.FullName);

    Sometimes I’ve made use of this functionality in WinForms “About” boxes, by enabling a “Show Loaded Assemblies” button if the program is running in Debug mode.

  2. Martijn Says:

    Hi Gareth,

    Thanks for the comment — I tried to keep things readable, but you are right of course.


  3. Mark Says:

    Excellent, this was very useful. I used it to know what classes are implementing an interface in a plugin based application when the plugins are loaded by another assembly.

Most popular

    Sorry. No data so far.

Recent Comments
  • Juan Romero: Hi there, it’s a neat little class, but I believe you could do the same thing with the WebClient...
  • anthosh: Hey, THank you very much for your tutorial. It was awesome. But i have a problem that i am not able to...
  • bian: how to get passphase if i have encrypt and decrypt string?? Thanks alot
  • Michael: Hi, I really like your post, thanks a lot, it really helped clear up a few things I could not remember how...
  • Bharat Prajapati: i was trying to import keyword dictionary to this plugin which is in csv format, but i get an error...