Share via


Assembly.GetModules Method

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets all the modules that are part of this assembly.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Function GetModules As Module()
public Module[] GetModules()

Return Value

Type: array<System.Reflection.Module[]
An array of modules.

Exceptions

Exception Condition
FileNotFoundException

The module to be loaded does not specify a file name extension.

Remarks

This method works on public and private resource files.

NoteNote:

Modules must be emitted with file name extensions.

Examples

The following example displays the name of the module in the returned array that contains the assembly manifest.

Imports System.Reflection

Public Class Example

   Public Shared Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)
      Dim mainAssembly As [Assembly] = [Assembly].GetExecutingAssembly()
      outputBlock.Text += String.Format("The executing assembly is {0}.", mainAssembly) & vbCrLf
      Dim mods() As [Module] = mainAssembly.GetModules()
      outputBlock.Text &= vbTab & "Modules in the assembly:" & vbCrLf
      For Each m As [Module] In mods
         outputBlock.Text &= vbTab & m.ToString() & vbCrLf
      Next
   End Sub 'Main
End Class 'Form1
using System;
using System.Reflection;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      Assembly mainAssembly = Assembly.GetExecutingAssembly();
      outputBlock.Text += String.Format("The executing assembly is {0}.", mainAssembly) + "\n";
      Module[] mods = mainAssembly.GetModules();
      outputBlock.Text += "\tModules in the assembly:" + "\n";
      foreach (Module m in mods)
         outputBlock.Text += String.Format("\t{0}", m) + "\n";
   }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.