Module 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
对模块执行反射。
public ref class Module abstractpublic ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::Serialization::ISerializablepublic ref class Module abstract : System::Reflection::ICustomAttributeProviderpublic ref class Module : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializablepublic ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializablepublic abstract class Modulepublic abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.Serialization.ISerializablepublic abstract class Module : System.Reflection.ICustomAttributeProvider[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
public class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializable[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializable[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.InteropServices._Module, System.Runtime.Serialization.ISerializabletype Module = classtype Module = class
    interface ICustomAttributeProvider
    interface ISerializabletype Module = class
    interface ICustomAttributeProvider[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Serializable>]
type Module = class
    interface _Module
    interface ISerializable
    interface ICustomAttributeProvider[<System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Module = class
    interface _Module
    interface ISerializable
    interface ICustomAttributeProviderPublic MustInherit Class ModulePublic MustInherit Class Module
Implements ICustomAttributeProvider, ISerializablePublic MustInherit Class Module
Implements ICustomAttributeProviderPublic Class Module
Implements _Module, ICustomAttributeProvider, ISerializablePublic MustInherit Class Module
Implements _Module, ICustomAttributeProvider, ISerializable- 继承
- 
				Module
- 派生
- 属性
- 实现
示例
以下代码示例演示如何使用反射来获取有关模块的信息:
using System.Reflection;
using System;
public class Program {
    public static void Main() {
        Class1 c1 = new Class1();
        //  Show the current module.
        Module m = c1.GetType().Module;
        Console.WriteLine("The current module is {0}.", m.Name);
        //  List all modules in the assembly.
        Assembly curAssembly = typeof(Program).Assembly;
        Console.WriteLine("The current executing assembly is {0}.", curAssembly);
        Module[] mods = curAssembly.GetModules();
        foreach (Module md in mods) {
            Console.WriteLine("This assembly contains the {0} module", md.Name);
        }
        Console.ReadLine();
    }
}
class Class1 {
}
Imports System.Reflection
Public Class Program
    Public Shared Sub Main()
        Dim c1 As New Class1
        ' Show the current module.
        ' Note the brackets around "[Module]" to differentiate 
        ' it from the Visual Basic "Module" keyword.
        Dim m As [Module] = c1.GetType().Module
        Console.WriteLine("The current module is {0}.", m.Name)
        ' List all modules in the assembly.
        Dim curAssembly As Assembly = GetType(Program).Assembly
        Console.WriteLine("The executing assembly is {0}.", curAssembly)
        Dim mods() As [Module] = curAssembly.GetModules()
        For Each md As [Module] In mods
            Console.WriteLine("This assembly contains the {0} module", md.Name)
        Next
        Console.ReadLine()
    End Sub
End Class
Class Class1
End Class
注解
模块是一个可移植的可执行文件,例如 type.dll 或 application.exe,由一个或多个类和接口组成。 单个模块可包含多个命名空间,而一个命名空间可跨越多个模块。
作为一个单元部署的一个或多个模块组成一个程序集。 有关创建具有多个模块的程序集的信息,请参阅 多文件程序集。
请注意,.NET Framework模块与 Visual Basic 中的模块不同,程序员使用它来组织应用程序中的函数和子例程。
构造函数
| Module() | 初始化 Module 类的新实例。 | 
字段
| FilterTypeName | 一个  | 
| FilterTypeNameIgnoreCase | 一个  | 
属性
| Assembly | |
| CustomAttributes | 获取包含此模型自定义属性的集合。 | 
| FullyQualifiedName | 获取表示此模块的完全限定名和路径的字符串。 | 
| MDStreamVersion | 获取元数据流版本。 | 
| MetadataToken | 获取一个令牌,该令牌用于标识元数据中的模块。 | 
| ModuleHandle | 获取模块的图柄。 | 
| ModuleVersionId | 获取可用于区分模块的两个版本的全局唯一标识符 (UUID)。 | 
| Name | 获取  | 
| ScopeName | 获取表示模块名的字符串。 | 
方法
运算符
| Equality(Module, Module) | 指示两个 Module 对象是否相等。 | 
| Inequality(Module, Module) | 指示两个 Module 对象是否不相等。 | 
显式接口实现
| _Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | 将一组名称映射为对应的一组调度标识符。 | 
| _Module.GetTypeInfo(UInt32, UInt32, IntPtr) | 检索对象的类型信息,然后可以使用该信息获取接口的类型信息。 | 
| _Module.GetTypeInfoCount(UInt32) | 检索对象提供的类型信息接口的数量(0 或 1)。 | 
| _Module.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | 提供对某一对象公开的属性和方法的访问。 | 
| ICustomAttributeProvider.GetCustomAttributes(Boolean) | 返回在该成员上定义的所有自定义特性的数组(已命名的特性除外),如果没有自定义特性,则返回空数组。 | 
| ICustomAttributeProvider.GetCustomAttributes(Type, Boolean) | 返回在该成员上定义、由类型标识的自定义属性数组,如果没有该类型的自定义属性,则返回空数组。 | 
| ICustomAttributeProvider.IsDefined(Type, Boolean) | 指示是否在该成员上定义了一个或多个  | 
扩展方法
| GetCustomAttribute(Module, Type) | 检索应用于指定模块的指定类型的自定义特性。 | 
| GetCustomAttribute<T>(Module) | 检索应用于指定模块的指定类型的自定义特性。 | 
| GetCustomAttributes(Module) | 检索应用于指定模块的自定义特性集合。 | 
| GetCustomAttributes(Module, Type) | 检索应用于指定模块的指定类型的自定义特性集合。 | 
| GetCustomAttributes<T>(Module) | 检索应用于指定模块的指定类型的自定义特性集合。 | 
| IsDefined(Module, Type) | 确定是否将指定类型的任何自定义属性应用于指定的模块。 | 
| GetModuleVersionId(Module) | 对模块执行反射。 | 
| HasModuleVersionId(Module) | 对模块执行反射。 |