Assembly.GetModule(String) 方法
定义
获取此程序集中的指定模块。Gets the specified module in this assembly.
public:
virtual System::Reflection::Module ^ GetModule(System::String ^ name);
public System.Reflection.Module GetModule (string name);
abstract member GetModule : string -> System.Reflection.Module
override this.GetModule : string -> System.Reflection.Module
Public Function GetModule (name As String) As Module
参数
- name
- String
请求的模块的名称。The name of the module being requested.
返回
所请求的模块,若未找到该模块则为 null
。The module being requested, or null
if the module is not found.
实现
异常
name
参数为 null
。The name
parameter is null
.
name
参数为空字符串 ("")。The name
parameter is an empty string ("").
无法加载已找到的文件。A file that was found could not be loaded.
未找到 name
。name
was not found.
name
不是有效的程序集。name
is not a valid assembly.
注解
此方法适用于文件名。This method works on file names.
Reflection.Emit
命名空间中的类发出动态模块的范围名称。Classes in the Reflection.Emit
namespace emit the scope name for a dynamic module. 作用域名称可由 Module.ScopeName 属性确定。The scope name can be determined by the Module.ScopeName property. 传递要 Assembly.GetModule
的模块的类型。Pass the kind of module you want to Assembly.GetModule
. 例如,如果你想要包含程序集清单的模块,请将模块的范围名称传递到 GetModule
。For example, if you want the module that contains the assembly manifest, pass the scope name of the module to GetModule
. 否则,传递模块的文件名。Otherwise, pass the file name of the module. 由具有 byte [] 参数的 Load
方法之一加载的程序集只有一个模块,即清单模块。Assemblies loaded by one of the Load
methods that have a byte[] parameter have only one module, and that is the manifest module. 始终使用作用域名称查找这些模块。Always seek these modules using the scope name.
可使用 Module.GetType 从特定模块检索类型。A type can be retrieved from a specific module using Module.GetType. 对包含清单的模块调用 Module.GetType
不会启动整个程序集的搜索。Calling Module.GetType
on the module containing the manifest will not initiate a search of the entire assembly. 若要从程序集检索类型(无论它位于哪个模块),必须调用 Assembly.GetType。To retrieve a type from an assembly, regardless of which module it is in, you must call Assembly.GetType.