Bewerken

Share via


Assembly.GetModules Method

Definition

Gets all the modules that are part of this assembly.

Overloads

GetModules()

Gets all the modules that are part of this assembly.

GetModules(Boolean)

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

GetModules()

Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs

Gets all the modules that are part of this assembly.

public:
 cli::array <System::Reflection::Module ^> ^ GetModules();
public:
 virtual cli::array <System::Reflection::Module ^> ^ GetModules();
public System.Reflection.Module[] GetModules ();
member this.GetModules : unit -> System.Reflection.Module[]
abstract member GetModules : unit -> System.Reflection.Module[]
override this.GetModules : unit -> System.Reflection.Module[]
Public Function GetModules () As Module()

Returns

Module[]

An array of modules.

Implements

Exceptions

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

Examples

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

using namespace System;
using namespace System::Reflection;
int main()
{
   Assembly^ mainAssembly = Assembly::GetExecutingAssembly();
   Console::WriteLine( "The executing assembly is {0}.", mainAssembly );
   array<Module^>^mods = mainAssembly->GetModules();
   Console::WriteLine( "\tModules in the assembly:" );
   for ( int i = 0; i < mods->Length; i++ )
      Console::WriteLine( "\t{0}", mods[ i ] );
}
using System;
using System.Reflection;

public class Example
{
    public static void Main()
    {
        Assembly mainAssembly = typeof(Example).Assembly;
        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);
    }
}
Imports System.Reflection

Public Class Example
    Public Shared Sub Main()
        Dim mainAssembly As Assembly = GetType(Example).Assembly
        Console.WriteLine("The executing assembly is {0}.", mainAssembly)
        Dim mods() As [Module] = mainAssembly.GetModules()
        Console.WriteLine(vbTab & "Modules in the assembly:")
        For Each m As [Module] In mods
            Console.WriteLine(vbTab & m.ToString())
        Next
    End Sub 
End Class

Remarks

This method works on public and private resource files.

Note

Modules must be emitted with file name extensions.

Applies to

GetModules(Boolean)

Source:
Assembly.cs
Source:
Assembly.cs
Source:
Assembly.cs

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

public:
 virtual cli::array <System::Reflection::Module ^> ^ GetModules(bool getResourceModules);
public virtual System.Reflection.Module[] GetModules (bool getResourceModules);
public System.Reflection.Module[] GetModules (bool getResourceModules);
abstract member GetModules : bool -> System.Reflection.Module[]
override this.GetModules : bool -> System.Reflection.Module[]
Public Overridable Function GetModules (getResourceModules As Boolean) As Module()
Public Function GetModules (getResourceModules As Boolean) As Module()

Parameters

getResourceModules
Boolean

true to include resource modules; otherwise, false.

Returns

Module[]

An array of modules.

Implements

Remarks

This method works on public and private resource files.

Note

Modules must be emitted with file name extensions.

Applies to