Redigeeri

Jagamisviis:


Module Class

Definition

Performs reflection on a module.

public ref class Module abstract
public ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::Serialization::ISerializable
public ref class Module abstract : System::Reflection::ICustomAttributeProvider
public ref class Module : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializable
public ref class Module abstract : System::Reflection::ICustomAttributeProvider, System::Runtime::InteropServices::_Module, System::Runtime::Serialization::ISerializable
public abstract class Module
public abstract class Module : System.Reflection.ICustomAttributeProvider, System.Runtime.Serialization.ISerializable
public 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.ISerializable
type Module = class
type Module = class
    interface ICustomAttributeProvider
    interface ISerializable
type 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 ICustomAttributeProvider
Public MustInherit Class Module
Public MustInherit Class Module
Implements ICustomAttributeProvider, ISerializable
Public MustInherit Class Module
Implements ICustomAttributeProvider
Public Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
Public MustInherit Class Module
Implements _Module, ICustomAttributeProvider, ISerializable
Inheritance
Module
Derived
Attributes
Implements

Examples

The following code examples show how to use reflection to get information about modules:

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

Remarks

A module is a portable executable file, such as type.dll or application.exe, consisting of one or more classes and interfaces. There may be multiple namespaces contained in a single module, and a namespace may span multiple modules.

One or more modules deployed as a unit compose an assembly. For information about creating an assembly with more than one module, see Multifile Assemblies.

Note that a .NET Framework module is not the same as a module in Visual Basic, which is used by a programmers to organize functions and subroutines in an application.

Constructors

Module()

Initializes a new instance of the Module class.

Fields

FilterTypeName

A TypeFilter object that filters the list of types defined in this module based upon the name. This field is case-sensitive and read-only.

FilterTypeNameIgnoreCase

A TypeFilter object that filters the list of types defined in this module based upon the name. This field is case-insensitive and read-only.

Properties

Assembly

Gets the appropriate Assembly for this instance of Module.

CustomAttributes

Gets a collection that contains this module's custom attributes.

FullyQualifiedName

Gets a string representing the fully qualified name and path to this module.

MDStreamVersion

Gets the metadata stream version.

MetadataToken

Gets a token that identifies the module in metadata.

ModuleHandle

Gets a handle for the module.

ModuleVersionId

Gets a universally unique identifier (UUID) that can be used to distinguish between two versions of a module.

Name

Gets a String representing the name of the module with the path removed.

ScopeName

Gets a string representing the name of the module.

Methods

Equals(Object)

Determines whether this module and the specified object are equal.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FindTypes(TypeFilter, Object)

Returns an array of classes accepted by the given filter and filter criteria.

GetCustomAttributes(Boolean)

Returns all custom attributes.

GetCustomAttributes(Type, Boolean)

Gets custom attributes of the specified type.

GetCustomAttributesData()

Returns a list of CustomAttributeData objects for the current module, which can be used in the reflection-only context.

GetField(String, BindingFlags)

Returns a field having the specified name and binding attributes.

GetField(String)

Returns a field having the specified name.

GetFields()

Returns the global fields defined on the module.

GetFields(BindingFlags)

Returns the global fields defined on the module that match the specified binding flags.

GetHashCode()

Returns the hash code for this instance.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetMethod(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Returns a method having the specified name, binding information, calling convention, and parameter types and modifiers.

GetMethod(String, Type[])

Returns a method having the specified name and parameter types.

GetMethod(String)

Returns a method having the specified name.

GetMethodImpl(String, BindingFlags, Binder, CallingConventions, Type[], ParameterModifier[])

Returns the method implementation in accordance with the specified criteria.

GetMethods()

Returns the global methods defined on the module.

GetMethods(BindingFlags)

Returns the global methods defined on the module that match the specified binding flags.

GetObjectData(SerializationInfo, StreamingContext)
Obsolete.

Provides an ISerializable implementation for serialized objects.

GetPEKind(PortableExecutableKinds, ImageFileMachine)

Gets a pair of values indicating the nature of the code in a module and the platform targeted by the module.

GetSignerCertificate()

Returns an X509Certificate object corresponding to the certificate included in the Authenticode signature of the assembly which this module belongs to. If the assembly has not been Authenticode signed, null is returned.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
GetType(String, Boolean, Boolean)

Returns the specified type, specifying whether to make a case-sensitive search of the module and whether to throw an exception if the type cannot be found.

GetType(String, Boolean)

Returns the specified type, searching the module with the specified case sensitivity.

GetType(String)

Returns the specified type, performing a case-sensitive search.

GetTypes()

Returns all the types defined within this module.

IsDefined(Type, Boolean)

Returns a value that indicates whether the specified attribute type has been applied to this module.

IsResource()

Gets a value indicating whether the object is a resource.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ResolveField(Int32, Type[], Type[])

Returns the field identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveField(Int32)

Returns the field identified by the specified metadata token.

ResolveMember(Int32, Type[], Type[])

Returns the type or member identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveMember(Int32)

Returns the type or member identified by the specified metadata token.

ResolveMethod(Int32, Type[], Type[])

Returns the method or constructor identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveMethod(Int32)

Returns the method or constructor identified by the specified metadata token.

ResolveSignature(Int32)

Returns the signature blob identified by a metadata token.

ResolveString(Int32)

Returns the string identified by the specified metadata token.

ResolveType(Int32, Type[], Type[])

Returns the type identified by the specified metadata token, in the context defined by the specified generic type parameters.

ResolveType(Int32)

Returns the type identified by the specified metadata token.

ToString()

Returns the name of the module.

Operators

Equality(Module, Module)

Indicates whether two Module objects are equal.

Inequality(Module, Module)

Indicates whether two Module objects are not equal.

Explicit Interface Implementations

_Module.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Maps a set of names to a corresponding set of dispatch identifiers.

_Module.GetTypeInfo(UInt32, UInt32, IntPtr)

Retrieves the type information for an object, which can then be used to get the type information for an interface.

_Module.GetTypeInfoCount(UInt32)

Retrieves the number of type information interfaces that an object provides (either 0 or 1).

_Module.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.

ICustomAttributeProvider.GetCustomAttributes(Boolean)

Returns an array of all of the custom attributes defined on this member, excluding named attributes, or an empty array if there are no custom attributes.

ICustomAttributeProvider.GetCustomAttributes(Type, Boolean)

Returns an array of custom attributes defined on this member, identified by type, or an empty array if there are no custom attributes of that type.

ICustomAttributeProvider.IsDefined(Type, Boolean)

Indicates whether one or more instance of attributeType is defined on this member.

Extension Methods

GetCustomAttribute(Module, Type)

Retrieves a custom attribute of a specified type that is applied to a specified module.

GetCustomAttribute<T>(Module)

Retrieves a custom attribute of a specified type that is applied to a specified module.

GetCustomAttributes(Module, Type)

Retrieves a collection of custom attributes of a specified type that are applied to a specified module.

GetCustomAttributes(Module)

Retrieves a collection of custom attributes that are applied to a specified module.

GetCustomAttributes<T>(Module)

Retrieves a collection of custom attributes of a specified type that are applied to a specified module.

IsDefined(Module, Type)

Indicates whether custom attributes of a specified type are applied to a specified module.

GetModuleVersionId(Module)
HasModuleVersionId(Module)

Applies to