Assembly.GetModules Method

July 28, 2014

Gets all the modules that are part of this assembly.

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

public Module[] GetModules()

Return Value

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

ExceptionCondition
FileNotFoundException

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

This method works on public and private resource files.

NoteNote:

Modules must be emitted with file name extensions.

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


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";
   }
}


Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft