Share via


Assembly.GetModule 方法

获取此程序集中的指定模块。

**命名空间:**System.Reflection
**程序集:**mscorlib(在 mscorlib.dll 中)

语法

声明
Public Function GetModule ( _
    name As String _
) As Module
用法
Dim instance As Assembly
Dim name As String
Dim returnValue As Module

returnValue = instance.GetModule(name)
public Module GetModule (
    string name
)
public:
virtual Module^ GetModule (
    String^ name
) sealed
public final Module GetModule (
    String name
)
public final function GetModule (
    name : String
) : Module

参数

  • name
    请求的模块的名称。

返回值

所请求的模块,若未找到该模块则为 空引用(在 Visual Basic 中为 Nothing)。

异常

异常类型 条件

ArgumentNullException

name 参数为 空引用(在 Visual Basic 中为 Nothing)。

ArgumentException

name 参数是空字符串 ("")。

FileLoadException

发现一个未能加载的文件。

FileNotFoundException

未找到 name。

BadImageFormatException

name 不是有效程序集。

备注

此方法对文件名有效。

Reflection.Emit 命名空间中的类发出动态模块的范围名。范围名可以由 Module.ScopeName 属性确定。将所需的模块种类传递给 Assembly.GetModule。例如,如果需要包含程序集清单的模块,请将模块的范围名传递给 GetModule。否则,传递模块的文件名。通过具有一个 byte[] 参数的 Load 方法之一加载的程序集只有一个模块,此模块就是清单模块。始终使用范围名查找这些模块。

可使用 Module.GetType 从特定模块检索类型。对包含清单的模块调用 Module.GetType 将不启动对整个程序集的搜索。若要从程序集检索类型,而不管该程序集所在的模块,则必须调用 Assembly.GetType

平台

Windows 98、Windows 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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

Assembly 类
Assembly 成员
System.Reflection 命名空间