List Assembly Dependencies

Problem

You want to list all the assemblies that are required by another assembly.

Solution

Use the Assembly.GetReferencedAssemblies method.

Discussion

All .NET assemblies include a header that lists assembly references. If the referenced assembly has a strong name, the header includes the required version and public key for the referenced assembly.

Once you retrieve a reference to an assembly, it’s easy to find its dependencies using the GetReferencedAssemblies method. Consider this code, which iterates through the assembly references of the current executing assembly:

Public Module TestReflection Public Sub Main() Dim ExecutingAssembly As System.Reflection.Assembly ExecutingAssembly = System.Reflection.Assembly.GetExecutingAssembly() ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook 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.