[C# Helper]
Index Books FAQ Contact About Rod
[Beginning Database Design Solutions, Second Edition]

[Beginning Software Engineering, Second Edition]

[Essential Algorithms, Second Edition]

[The Modern C# Challenge]

[WPF 3d, Three-Dimensional Graphics with WPF and C#]

[The C# Helper Top 100]

[Interview Puzzles Dissected]

[C# 24-Hour Trainer]

[C# 5.0 Programmer's Reference]

[MCSD Certification Toolkit (Exam 70-483): Programming in C#]

Title: List a program's loaded assemblies in C#

[List a program's loaded assemblies in C#]

The key to this example is the following ListAssemblies method.

// List the assemblies. private void ListAssemblies() { lblNumAssemblies.Text = ""; lstAssemblies.Items.Clear(); Cursor = Cursors.WaitCursor; Refresh(); foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) { lstAssemblies.Items.Add(assembly.GetName().Name); } // Display the number of assemblies. lblNumAssemblies.Text = lstAssemblies.Items.Count.ToString() + " assemblies"; Cursor = Cursors.Default; }

To list the assemblies that the program has loaded, the code calls AppDomain.CurrentDomain.GetAssemblies and loops over the Assembly objects that it returns. The program calls each object's GetName method to get an AssemblyName object for it. It displays the value of that object's Name property in the list box.

Download the example to experiment with it and to see additional details.

© 2009-2023 Rocky Mountain Computer Consulting, Inc. All rights reserved.