public class ModuleBuilder : Module
|
Assembly (inherited from System.Reflection.Module) |
Read-only See base class member description: System.Reflection.Module.Assembly Gets the appropriate Assembly for this instance of Module. |
FullyQualifiedName | Read-only Overridden: Gets a String representing the fully-qualified name and path to this module. |
Name (inherited from System.Reflection.Module) |
Read-only See base class member description: System.Reflection.Module.Name Gets a String representing the name of the module with the path removed. |
ScopeName (inherited from System.Reflection.Module) |
Read-only See base class member description: System.Reflection.Module.ScopeName Gets a string representing the name of the module. |
CreateGlobalFunctions | Complete the global function definitions for this dynamic module. |
DefineDocument | Define a document for source. |
DefineEnum | Defines an enumeration type with that is a value type with a single non-static field called value__ of the specified type. |
DefineGlobalMethod | Overloaded:DefineGlobalMethod(string name, MethodAttributes attributes, Type returnType, Type[] parameterTypes) Defines a global method given its name, attributes, return type, and parameter types. |
DefineGlobalMethod | Overloaded:DefineGlobalMethod(string name, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes) Defines a global method given its name, attributes, calling convention, return type, and parameter types. |
DefineInitializedData | Defines initialized data field in the .sdata section of the portable executable (PE) file. |
DefinePInvokeMethod | Overloaded:DefinePInvokeMethod(string name, string dllName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) Defines a PInvoke method given its name, the name of the DLL in which the method is defined, the attributes of the method, the calling convention of the method, the return type of the method, the types of the parameters of the method, and the PInvoke flags. |
DefinePInvokeMethod | Overloaded:DefinePInvokeMethod(string name, string dllName, string entryName, MethodAttributes attributes, CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv, CharSet nativeCharSet) Defines a PInvoke method given its name, the name of the DLL in which the method is defined, the attributes of the method, the calling convention of the method, the return type of the method, the types of the parameters of the method, and the PInvoke flags. |
DefineResource | Overloaded:DefineResource(string name, string description) Defines the named managed embedded resource to be stored in this module. |
DefineResource | Overloaded:DefineResource(string name, string description, ResourceAttributes attribute) Defines the named managed embedded resource with the given attributes that is to be stored in this module. |
DefineType | Overloaded:DefineType(string name) Constructs a TypeBuilder for a type with the specified name. |
DefineType | Overloaded:DefineType(string name, TypeAttributes attr) Constructs a TypeBuilder given the type name and the type attributes. |
DefineType | Overloaded:DefineType(string name, TypeAttributes attr, Type parent) Constructs a TypeBuilder given type name, its attributes, and the type that the defined type extends. |
DefineType | Overloaded:DefineType(string name, TypeAttributes attr, Type parent, int typesize) Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends, and the total size of the type. |
DefineType | Overloaded:DefineType(string name, TypeAttributes attr, Type parent, PackingSize packsize) Constructs a TypeBuilder given the type name, the attributes, the type that the defined type extends, and the packing size of the type. |
DefineType | Overloaded:DefineType(string name, TypeAttributes attr, Type parent, Type[] interfaces) Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends, and the interfaces that the defined type implements. |
DefineType | Overloaded:DefineType(string name, TypeAttributes attr, Type parent, PackingSize packingSize, int typesize) Constructs a TypeBuilder given the type name, attributes, the type that the defined type extends, the packing size of the defined type, and the total size of the defined type. |
DefineUninitializedData | Defines uninitialized data field in the .sdata section of the portable executable (PE) file. |
DefineUnmanagedResource | Overloaded:DefineUnmanagedResource(byte[] resource) Defines an unmanaged embedded resource given an opaque blob of bytes. |
DefineUnmanagedResource | Overloaded:DefineUnmanagedResource(string resourceFileName) Defines an unmanaged resource given the name of Win32 resource file. |
Equals (inherited from System.Object) |
See base class member description: System.Object.Equals Derived from System.Object, the primary base class for all objects. |
FindTypes (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.FindTypes Returns an array of classes accepted by the given filter and filter criteria. |
GetArrayMethod | Returns the named method on an array class. |
GetArrayMethodToken | Returns the token for the named method on an array class. |
GetConstructorToken | Returns the token used to identify the specified constructor within this module. |
GetCustomAttributes (inherited from System.Reflection.Module) |
Overloaded:GetCustomAttributes(bool inherit) See base class member description: System.Reflection.Module.GetCustomAttributesReturns all custom attributes. |
GetCustomAttributes (inherited from System.Reflection.Module) |
Overloaded:GetCustomAttributes(Type attributeType, bool inherit) See base class member description: System.Reflection.Module.GetCustomAttributesGets custom attributes of the specified type. |
GetField (inherited from System.Reflection.Module) |
Overloaded:GetField(string name) See base class member description: System.Reflection.Module.GetFieldReturns a field having the specified name. |
GetField (inherited from System.Reflection.Module) |
Overloaded:GetField(string name, BindingFlags bindingAttr) See base class member description: System.Reflection.Module.GetFieldReturns a field having the specified name and binding attributes. |
GetFields (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.GetFields Returns an array of fields implemented by a class. |
GetFieldToken | Returns the token used to identify the specified field within this module. |
GetHashCode (inherited from System.Object) |
See base class member description: System.Object.GetHashCode Derived from System.Object, the primary base class for all objects. |
GetMethod (inherited from System.Reflection.Module) |
Overloaded:GetMethod(string name) See base class member description: System.Reflection.Module.GetMethodReturns a method having the specified name. |
GetMethod (inherited from System.Reflection.Module) |
Overloaded:GetMethod(string name, Type[] types) See base class member description: System.Reflection.Module.GetMethodReturns a method having the specified name and parameter types. |
GetMethod (inherited from System.Reflection.Module) |
Overloaded:GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers) See base class member description: System.Reflection.Module.GetMethodReturns a method having the specified name, binding information, calling convention, and parameter types and modifiers. |
GetMethods (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.GetMethods Returns an array of all the global methods defined on the module. |
GetMethodToken | Returns the token used to identify the specified method within this module. |
GetObjectData (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.GetObjectData Provides an ISerializable implementation for serialized objects. |
GetSignatureToken | Overloaded:GetSignatureToken(SignatureHelper sigHelper) Defines a signature token using the given SignatureHelper object. |
GetSignatureToken | Overloaded:GetSignatureToken(byte[] sigBytes, int sigLength) Defines a signature token specified by the character array and signature length. |
GetStringConstant | Returns the token of the given string in the module's constant pool. |
GetSymWriter | Returns the symbol writer associated with this dynamic module. |
GetType (inherited from System.Object) |
Overloaded:GetType() See base class member description: System.Object.GetTypeDerived from System.Object, the primary base class for all objects. |
GetType | Overloaded:GetType(string className) Overridden: Gets the named type defined in the module. |
GetType | Overloaded:GetType(string className, bool ignoreCase) Overridden: Gets the named type defined in the module optionally ignoring the case of the type name. |
GetType | Overloaded:GetType(string className, bool throwOnError, bool ignoreCase) Overridden: Gets the named type defined in the module optionally ignoring the case of the type name. Optionally throws an exception if the type is not found. |
GetTypes | Overridden: Returns all the classes defined within this module. |
GetTypeToken | Overloaded:GetTypeToken(string name) Returns the token used to identify the type given its name. |
GetTypeToken | Overloaded:GetTypeToken(Type type) Returns the token used to identify the specified type within this module. |
IsDefined (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.IsDefined Determines if the specified attributeType is defined on this module. |
IsResource (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.IsResource Gets a value indicating whether the object is a resource. |
IsTransient | Checks if this dynamic module is transient. |
SetCustomAttribute | Overloaded:SetCustomAttribute(CustomAttributeBuilder customBuilder) Set a custom attribute using a custom attribute builder. |
SetCustomAttribute | Overloaded:SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute) Set a custom attribute using a specified custom attribute blob. |
SetSymCustomAttribute | Sets the custom attribute that is stored with the symbolic information. |
SetUserEntryPoint | Sets the user entry point. |
ToString (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.ToString Returns the name of the module. |
Finalize (inherited from System.Object) |
See base class member description: System.Object.Finalize Derived from System.Object, the primary base class for all objects. |
GetMethodImpl (inherited from System.Reflection.Module) |
See base class member description: System.Reflection.Module.GetMethodImpl Returns the method implementation in accordance with the specified criteria. |
MemberwiseClone (inherited from System.Object) |
See base class member description: System.Object.MemberwiseClone Derived from System.Object, the primary base class for all objects. |
Hierarchy:
public Assembly Assembly {get;}
|
public override string FullyQualifiedName {get;}
|
public string Name {get;}
|
To get the name and the path, use Module.FullyQualifiedName.
using System.Reflection; using System; public class Simple { public static void Main () { Module mod = Assembly.GetExecutingAssembly().GetModules () [0]; Console.WriteLine ("Module Name is " + mod.Name); Console.WriteLine ("Module FullyQualifiedName is " + mod.FullyQualifiedName); Console.WriteLine ("Module ScopeName is " + mod.ScopeName); } } /* This code produces the following output: Module Name is modname.exe Module FullyQualifiedName is C:\Bin\modname.exe Module ScopeName is modname.exe */
public string ScopeName {get;}
|
using System.Reflection; using System; public class Simple { public static void Main () { Module mod = Assembly.GetExecutingAssembly().GetModules () [0]; Console.WriteLine ("Module Name is " + mod.Name); Console.WriteLine ("Module FullyQualifiedName is " + mod.FullyQualifiedName); Console.WriteLine ("Module ScopeName is " + mod.ScopeName); } } /* Produces this output: Module Name is modname.exe Module FullyQualifiedName is C:\Bin\modname.exe Module ScopeName is modname.exe */
public void CreateGlobalFunctions(); |
Exception Type | Condition |
---|---|
InvalidOperationException | This method was called previously. |
public ISymbolDocumentWriter DefineDocument( |
url
language
languageVendor
documentType
Exception Type | Condition |
---|---|
ArgumentNullException | url is null. |
InvalidOperationException | This method is called on a dynamic module that is not a debug module. |
public EnumBuilder DefineEnum( |
name
visibility
underlyingType
Exception Type | Condition |
---|---|
ArgumentException | Attributes other than visibility attributes are provided. -or- An enum with the given name exists in the parent assembly of this module. -or- When the visibility attributes are incorrect for the scope of the enum. For example, if TypeAttributes.NestedPublic is specified as the visibility but the enum is not a nested type. |
ArgumentNullException | name is null. |
public MethodBuilder DefineGlobalMethod( |
name
attributes
returnType
parameterTypes
Exception Type | Condition |
---|---|
ArgumentException | The method is not static. -or- The length of name is zero |
ArgumentNullException | name is null. |
InvalidOperationException | ModuleBuilder.CreateGlobalFunctions has been previously called. |
public MethodBuilder DefineGlobalMethod( |
name
attributes
callingConvention
returnType
parameterTypes
Exception Type | Condition |
---|---|
ArgumentException | The method is not static. |
ArgumentNullException | name is null. |
InvalidOperationException | ModuleBuilder.CreateGlobalFunctions has been previously called. |
public FieldBuilder DefineInitializedData( |
name
data
attributes
Exception Type | Condition |
---|---|
ArgumentNullException | name is null. |
InvalidOperationException | ModuleBuilder.CreateGlobalFunctions has been previously called. |
public MethodBuilder DefinePInvokeMethod( |
name
dllName
attributes
callingConvention
returnType
parameterTypes
nativeCallConv
nativeCharSet
Exception Type | Condition |
---|---|
ArgumentException | The method is not static or if the containing type is an interface. -or- The method is abstract. -or- The method was previously defined. |
ArgumentNullException | name or dllName is null. |
InvalidOperationException | The containing type has been previously created using TypeBuilder.CreateType |
public MethodBuilder DefinePInvokeMethod( |
name
dllName
entryName
attributes
callingConvention
returnType
parameterTypes
nativeCallConv
nativeCharSet
Exception Type | Condition |
---|---|
ArgumentException | The method is not static or if the containing type is an interface or if the method is abstract of if the method was previously defined. |
ArgumentNullException | name or dllName is null. |
InvalidOperationException | The containing type has been previously created using TypeBuilder.CreateType |
public IResourceWriter DefineResource( |
name
description
Exception Type | Condition |
---|---|
ArgumentException | Length of name is zero. |
ArgumentNullException | name is null. |
InvalidOperationException | This module is transient. -or- The containing assembly is not persistable. |
public IResourceWriter DefineResource( |
name
description
attribute
Exception Type | Condition |
---|---|
ArgumentException | Length of name is zero. |
ArgumentNullException | name is null. |
InvalidOperationException | This module is transient. -or- The containing assembly is not persistable. |
public TypeBuilder DefineType( |
name
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module. |
ArgumentNullException | name is null. |
AssemblyName asmname = new AssemblyName(); asmname.Name = "assemfilename.exe"; AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain(). DefineDynamicAssembly(asmname, AssemblyBuilderAccess.RunAndSave); ModuleBuilder modbuild = asmbuild.DefineDynamicModule( "modulename", "assemfilename.exe" ); TypeBuilder typebuild1 = modbuild.DefineType( "typename" ); typebuild1.CreateType(); asmbuild.Save( "assemfilename.exe" );
public TypeBuilder DefineType( |
name
attr
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module. |
ArgumentNullException | name is null. |
public TypeBuilder DefineType( |
name
attr
parent
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module. |
ArgumentNullException | name is null. |
public TypeBuilder DefineType( |
name
attr
parent
typesize
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module. |
ArgumentNullException | name is null. |
public TypeBuilder DefineType( |
name
attr
parent
packsize
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module. |
ArgumentNullException | name is null. |
public TypeBuilder DefineType( |
name
attr
parent
interfaces
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module. |
ArgumentNullException | name is null. |
public TypeBuilder DefineType( |
name
attr
parent
packingSize
typesize
Exception Type | Condition |
---|---|
ArgumentException | A type with the given name exists in the parent assembly of this module |
ArgumentNullException | name is null. |
public FieldBuilder DefineUninitializedData( |
name
size
attributes
Exception Type | Condition |
---|---|
ArgumentNullException | name is null. |
InvalidOperationException | ModuleBuilder.CreateGlobalFunctions has been previously called. |
public void DefineUnmanagedResource( |
resource
Exception Type | Condition |
---|---|
ArgumentException | An unmanaged resource has already been defined in the module's assembly. |
ArgumentNullException | resource is null. |
public void DefineUnmanagedResource( |
resourceFileName
Exception Type | Condition |
---|---|
ArgumentException | An unmanaged resource has already been defined in the module's assembly. -or- resourceFileName is the empty string (""). |
ArgumentNullException | resource is null. |
FileNotFoundException | resourceFileName is not found -or- resourceFileName is a directory |
~ModuleBuilder(); |
public virtual Type[] FindTypes( |
filter
filterCriteria
Exception Type | Condition |
---|---|
ReflectionTypeLoadException | One or more classes in a module could not be loaded. |
The delegate given by filter is called for each class in the module, passing along the Type object representing the class as well as the given filterCriteria. If filter returns a particular class, that class will be included in the returned array. If filter returns null, all classes are returned and filterCriteria is ignored.
FindTypes cannot be used to look up parameterized types such as arrays.
public MethodInfo GetArrayMethod( |
arrayClass
methodName
callingConvention
returnType
parameterTypes
Exception Type | Condition |
---|---|
ArgumentException | arrayClass is not an array. |
ArgumentNullException | arrayClass or methodName is null. |
public MethodToken GetArrayMethodToken( |
arrayClass
methodName
callingConvention
returnType
parameterTypes
Exception Type | Condition |
---|---|
ArgumentException | arrayClass is not an array. -or- Length of methodName is zero. |
ArgumentNullException | arrayClass or methodName is null. |
public MethodToken GetConstructorToken( |
con
Exception Type | Condition |
---|---|
ArgumentNullException | con is null. |
inherit
attributeType
inherit
Exception Type | Condition |
---|---|
ArgumentNullException | attributeType is null. |
name
Exception Type | Condition |
---|---|
ArgumentException | The name parameter is null. |
public FieldInfo GetField( |
name
bindingAttr
Exception Type | Condition |
---|---|
ArgumentException | The name parameter is null. |
public FieldInfo[] GetFields(); |
public FieldToken GetFieldToken( |
field
Exception Type | Condition |
---|---|
ArgumentNullException | con is null. |
InvalidOperationException | The field is defined in a different module. |
public virtual int GetHashCode(); |
public MethodInfo GetMethod( |
name
Exception Type | Condition |
---|---|
ArgumentNullException | name is null. |
public MethodInfo GetMethod( |
name
types
Exception Type | Condition |
---|---|
ArgumentNullException | name is null, types is null, or types (i) is null. |
public MethodInfo GetMethod( |
name
bindingAttr
binder
callConvention
types
modifiers
Exception Type | Condition |
---|---|
ArgumentNullException | name is null, types is null, or types (i) is null. |
protected virtual MethodInfo GetMethodImpl( |
name
bindingAttr
binder
callConvention
types
modifiers
Exception Type | Condition |
---|---|
AmbiguousMatchException | types is null. |
public MethodInfo[] GetMethods(); |
public MethodToken GetMethodToken( |
method
Exception Type | Condition |
---|---|
ArgumentNullException | method is null. |
InvalidOperationException | The declaring type for the method is not in this module. |
public virtual void GetObjectData( |
info
context
Exception Type | Condition |
---|---|
ArgumentNullException | info is null. |
public SignatureToken GetSignatureToken( |
sigHelper
Exception Type | Condition |
---|---|
ArgumentNullException | sigHelper is null. |
public SignatureToken GetSignatureToken( |
sigBytes
sigLength
public StringToken GetStringConstant( |
str
Exception Type | Condition |
---|---|
ArgumentNullException | str is null. |
public ISymbolWriter GetSymWriter(); |
public Type GetType(); |
className
Exception Type | Condition |
---|---|
ArgumentException | Length of className is zero or if length of className is greater than 1023. |
ArgumentNullException | className is null. |
SecurityException | The requested Type is non-public and the caller does not have ReflectionPermission to reflect non-public objects outside the current assembly. |
TargetInvocationException | A class initializer is invoked and throws an exception. |
TypeLoadException | An error is encountered while loading the Type. |
className
ignoreCase
Exception Type | Condition |
---|---|
ArgumentException | Length of className is zero. -or- The length of className is greater than 1023. |
ArgumentNullException | className is null. |
SecurityException | The requested Type is non-public and the caller does not have ReflectionPermission to reflect non-public objects outside the current assembly. |
TargetInvocationException | A class initializer is invoked and throws an exception. |
className
throwOnError
ignoreCase
Exception Type | Condition |
---|---|
ArgumentException | Length of className is zero. -or- The length of className is greater than 1023. |
ArgumentNullException | className is null. |
SecurityException | The requested Type is non-public and the caller does not have ReflectionPermission to reflect non-public objects outside the current assembly. |
TargetInvocationException | A class initializer is invoked and throws an exception. |
TypeLoadException | throwOnError is true and an error is encountered while loading the Type. |
public override Type[] GetTypes(); |
Exception Type | Condition |
---|---|
ReflectionTypeLoadException | One or more classes in a module could not be loaded. |
SecurityException | The caller does not have the required permission. |
For example, if the class initializers of one of the classes throws an exception while it is being loaded, a TargetInvocationException is stored in the corresponding element of the LoaderExceptions array.
name
Exception Type | Condition |
---|---|
ArgumentException | type is a ByRef or type is a SymbolType that is not a pointer or an array. |
ArgumentNullException | type is null. |
InvalidOperationException | This is a non-transient module that references a transient module. |
TypeLoadException | The type named name cannot be found. |
type
Exception Type | Condition |
---|---|
ArgumentException | type is a ByRef or type is a SymbolType that is not a pointer or an array. |
ArgumentNullException | type is null. |
InvalidOperationException | A non-transient module that references a transient module. |
attributeType
inherit
Exception Type | Condition |
---|---|
ArgumentNullException | attributeType is null. |
public bool IsResource(); |
public bool IsTransient(); |
protected object MemberwiseClone(); |
public void SetCustomAttribute( |
customBuilder
Exception Type | Condition |
---|---|
ArgumentNullException | con is null. |
public void SetCustomAttribute( |
con
binaryAttribute
Exception Type | Condition |
---|---|
ArgumentNullException | con or binaryAttribute is null. |
name
data
Exception Type | Condition |
---|---|
ArgumentNullException | url is null. |
InvalidOperationException | This method is called on a dynamic module that is not a debug module. |
public void SetUserEntryPoint( |
entryPoint
Exception Type | Condition |
---|---|
ArgumentNullException | entryPoint is null. |
InvalidOperationException | This method is called on a dynamic module that is not a debug module. -or- entryPoint is not contained in this dynamic module. |
public override string ToString(); |