Export (0) Print
Expand All

Assembly.GetModules Method

Gets all the modules that are part of this assembly.

Overload List

Gets all the modules that are part of this assembly.

Supported by the .NET Compact Framework.

[Visual Basic] Overloads Public Function GetModules() As Module()
[C#] public Module[] GetModules();
[C++] public: Module* GetModules() [];
[JScript] public function GetModules() : Module[];

Gets all the modules that are part of this assembly, specifying whether to include resource modules.

[Visual Basic] Overloads Public Function GetModules(Boolean) As Module()
[C#] public Module[] GetModules(bool);
[C++] public: Module* GetModules(bool) [];
[JScript] public function GetModules(Boolean) : Module[];

Example

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

[Visual Basic] 
Imports System
Imports System.Reflection

Public Class Form1

    Public Shared Sub Main()
        Dim mainAssembly As [Assembly] = [Assembly].GetExecutingAssembly()
        Dim mainMod As [Module] = mainAssembly.GetModules()(0)
        Console.WriteLine("The executing assembly is {0}.", mainAssembly)
    End Sub 'Main
End Class 'Form1

[C#] 
using System;
using System.Reflection;

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

[C++] 
#using <mscorlib.dll>

using namespace System;
using namespace System::Reflection;

int main() {
   Assembly*  mainAssembly = Assembly::GetExecutingAssembly();
   Module*  mainMod = mainAssembly->GetModules()[0];
   Console::WriteLine(S"The executing assembly is {0}.", mainAssembly);
}

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

See Also

Assembly Class | Assembly Members | System.Reflection Namespace

Show:
© 2014 Microsoft