using dnlib.DotNet; class ModuleEntryPointFinder { public static void Main(string[] args) { string path = "MyModule.dll"; ModuleDefMD module = ModuleDefMD.Load(path); MethodDef entryPoint = module.EntryPoint; Console.WriteLine("The entry point of the module is " + entryPoint.FullName); } }
using dnlib.DotNet; class ModuleTypeLister { public static void Main(string[] args) { string path = "MyModule.dll"; ModuleDefMD module = ModuleDefMD.Load(path); TypeDef[] types = module.GetTypes().ToArray(); for (int i = 0; i < types.Length; i++) { Console.WriteLine("Type #" + i + ": " + types[i].FullName); } } }In this example, we again use the Load method of the ModuleDefMD class to load the specified module into memory. We then use the GetTypes method to get an enumeration of all the types in the module, which we convert to an array and iterate over to print out the full name of each type. The dnlib.DotNet package library provides an extensive set of .NET metadata manipulation classes that include ModuleDefMD. This package provides comprehensive functionality for reading, writing, and modifying .NET assembly metadata.