Ask Learn
Preview
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets all the modules that are part of this assembly.
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. |
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()
An array of modules.
The module to be loaded does not specify a file name extension.
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 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
This method works on public and private resource files.
Note
Modules must be emitted with file name extensions.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
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()
true
to include resource modules; otherwise, false
.
An array of modules.
This method works on public and private resource files.
Note
Modules must be emitted with file name extensions.
Product | Versions |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Ask Learn is an AI assistant that can answer questions, clarify concepts, and define terms using trusted Microsoft documentation.
Please sign in to use Ask Learn.
Sign in