Assembly.GetModules Assembly.GetModules Assembly.GetModules Assembly.GetModules Method

定义

获取作为此程序集的一部分的所有模块。Gets all the modules that are part of this assembly.

重载

GetModules() GetModules() GetModules() GetModules()

获取作为此程序集的一部分的所有模块。Gets all the modules that are part of this assembly.

GetModules(Boolean) GetModules(Boolean) GetModules(Boolean) GetModules(Boolean)

获取属于此程序集的所有模块,同时指定是否包括资源模块。Gets all the modules that are part of this assembly, specifying whether to include resource modules.

GetModules() GetModules() GetModules() GetModules()

获取作为此程序集的一部分的所有模块。Gets all the modules that are part of this assembly.

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

返回

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 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 

注解

此方法适用于公共和专用的资源文件。This method works on public and private resource files.

备注

模块必须发出具有文件扩展名。Modules must be emitted with file name extensions.

GetModules(Boolean) GetModules(Boolean) GetModules(Boolean) GetModules(Boolean)

获取属于此程序集的所有模块,同时指定是否包括资源模块。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);
abstract member GetModules : bool -> System.Reflection.Module[]
override this.GetModules : bool -> System.Reflection.Module[]
Public Overridable Function GetModules (getResourceModules As Boolean) As Module()

参数

getResourceModules
Boolean Boolean Boolean Boolean

true 则包括资源模块;否则,为 falsetrue to include resource modules; otherwise, false.

返回

Module[]

模块的数组。An array of modules.

实现

注解

此方法适用于公共和专用的资源文件。This method works on public and private resource files.

备注

模块必须发出具有文件扩展名。Modules must be emitted with file name extensions.

适用于