O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required