using dnlib.DotNet; ModuleDefMD module = ModuleDefMD.Load("MyApp.exe"); foreach (var assemblyRef in module.GetAssemblyRefs()) { Console.WriteLine(assemblyRef.FullName); }
using dnlib.DotNet; ModuleDefMD module = ModuleDefMD.Load("MyLibrary.dll"); foreach (var assemblyRef in module.GetAssemblyRefs()) { if (assemblyRef.Name == "Newtonsoft.Json") { Console.WriteLine("MyLibrary.dll uses the Newtonsoft.Json package"); } }This code example loads a .NET assembly file and retrieves all the referenced assemblies in it by calling the GetAssemblyRefs method of the ModuleDefMD class. It then checks if the assembly references the Newtonsoft.Json assembly and prints a message to the console indicating that the assembly uses the Newtonsoft.Json package. In both examples, the dnlib library is used along with ModuleDefMD class to access metadata of a .NET module. The GetAssemblyRefs method is used to retrieve referenced assemblies, which can be used to determine package dependencies of an assembly or application.