23.3. Programmatic Access to Assemblies

Fortunately, .NET assemblies are not just black boxes. A .NET assembly is represented by the Assembly class of the System.Reflection namespace. You can use this class to gain programmatic access to the components of an assembly. Listing 23.5 shows how to load the assemblies created earlier and explore them.

Listing 23.5. Loading and Browsing an Assembly in C#
 using System; using System.Reflection; public class AssemblyExplore { public static void Main(string[] args) { Assembly asm = Assembly.LoadFrom("C:\\BOOK\\ code\\Chapter 23\\Greeting.exe"); //Prints the properties of the assembly PrintProperties(asm); //Browse the modules of the assembly BrowseModules(asm); } private static void PrintProperties(Assembly ...

Get .NET for Java Developers: Migrating to C# now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.