Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Assembly.GetModules Method ()

Gets all the modules that are part of this assembly.

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

public Module[] GetModules ()
public final Module[] GetModules ()
public final function GetModules () : Module[]
Not applicable.

Return Value

An array of modules.

Exception typeCondition

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 Form1
{
    public static void Main()
    {
        Assembly mainAssembly = Assembly.GetExecutingAssembly();
        Console.WriteLine("The executing assembly is {0}.", mainAssembly);
        Module[] mods = mainAssembly.GetModules();
        Console.WriteLine("\tModules in the assembly:");
        foreach (Module m in mods)
            Console.WriteLine("\t{0}", m);
    }
}

import System.*;
import System.Reflection.*;

public class Form1
{
    public static void main(String[] args)
    {
        Assembly mainAssembly = Assembly.GetExecutingAssembly();
        Module mainMod = mainAssembly.GetModules()[0];
        Console.WriteLine("The executing assembly is {0}.", mainAssembly);
    } //main
} //Form1

var mainAssembly : Assembly = Assembly.GetExecutingAssembly();
var mainMod : Module = mainAssembly.GetModules()[0];
Console.WriteLine("Module name: {0}", mainMod.Name);

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

Show:
© 2014 Microsoft