System.Reflection.Assembly Class

Represents an assembly, which is a reusable, versionable, and self-describing building block of a common language runtime application.

See Also: Assembly

Syntax

[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComDefaultInterface(typeof(System.Runtime.InteropServices._Assembly))]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Assembly : ICustomAttributeProvider, _Assembly, ISerializable, IEvidenceFactory

Remarks

Use the Assembly class to load assemblies, to explore the metadata and constituent parts of assemblies, to discover the types contained in assemblies, and to create instances of those types.

To get an array of Assembly objects representing the assemblies currently loaded into an application domain (for example, the default application domain of a simple project), use the AppDomain.GetAssemblies method.

To load assemblies dynamically, the Assembly class provides the following static methods (Shared methods in Visual Basic). Assemblies are loaded into the application domain where the load operation occurs.

To get an Assembly object for the currently executing assembly, use the Assembly.GetExecutingAssembly method.

Many members of the Assembly class provide information about an assembly. For example:

The Assembly.GetTypes method lists all the types in the assembly. The Assembly.GetExportedTypes method lists the types that are visible to callers outside the assembly. The erload:System.Reflection.Assembly.GetType method can be used to search for a particular type in the assembly. The erload:System.Reflection.Assembly.CreateInstance method can be used to search for and create instances of types in the assembly.

For more information on assemblies, see Application Domains and Assemblies.

Thread Safety

This type is safe for multithreaded operations.

Requirements

Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0

The members of System.Reflection.Assembly are listed below.

See Also: Object

Protected Constructors

Initializes a new instance of the Assembly class.

Public Properties

[read-only]
CodeBaseString.

Gets the location of the assembly as specified originally, for example, in an AssemblyName object.

[read-only]
CustomAttributesIEnumerable<CustomAttributeData>.

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

[read-only]
DefinedTypesIEnumerable<TypeInfo>.

Gets a collection of the types defined in this assembly.

[read-only]
EntryPointMethodInfo.

Gets the entry point of this assembly.

[read-only]
EscapedCodeBaseString.

Gets the URI, including escape characters, that represents the codebase.

[read-only]
EvidenceEvidence.

Gets the evidence for this assembly.

[read-only]
ExportedTypesIEnumerable<Type>.

Gets a collection of the public types defined in this assembly that are visible outside the assembly.

[read-only]
FullNameString.

Gets the display name of the assembly.

[read-only]
GlobalAssemblyCacheBoolean.

Gets a value indicating whether the assembly was loaded from the global assembly cache.

[read-only]
HostContextInt64.

Gets the host context with which the assembly was loaded.

[read-only]
ImageRuntimeVersionString.

Gets a string representing the version of the common language runtime (CLR) saved in the file containing the manifest.

[read-only]
IsDynamicBoolean.

Gets a value that indicates whether the current assembly was generated dynamically in the current process by using reflection emit.

[read-only]
IsFullyTrustedBoolean.

Gets a value that indicates whether the current assembly is loaded with full trust.

[read-only]
LocationString.

Gets the full path or UNC location of the loaded file that contains the manifest.

[read-only]
ManifestModuleModule.

Gets the module that contains the manifest for the current assembly.

[read-only]
ModulesIEnumerable<Module>.

Gets a collection that contains the modules in this assembly.

[read-only]
PermissionSetPermissionSet.

Gets the grant set of the current assembly.

[read-only]
ReflectionOnlyBoolean.

Gets a Boolean value indicating whether this assembly was loaded into the reflection-only context.

[read-only]
SecurityRuleSetSecurityRuleSet.

Gets a value that indicates which set of security rules the common language runtime (CLR) enforces for this assembly.

Public Methods

CreateInstance(String) : Object

Locates the specified type from this assembly and creates an instance of it using the system activator, using case-sensitive search.

CreateInstance(String, Boolean) : Object

Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search.

CreateInstance(String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Object[]) : Object

Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search and having the specified culture, arguments, and binding and activation attributes.

static
CreateQualifiedName(String, String) : String

Creates the name of a type qualified by the display name of its assembly.

override
Equals(Object) : Boolean

Determines whether this assembly and the specified object are equal.

static
GetAssembly(Type) : Assembly

Gets the currently loaded assembly in which the specified class is defined.

static
GetCallingAssembly() : Assembly

Returns the Assembly of the method that invoked the currently executing method.

GetCustomAttributes(Boolean) : Object[]

Gets all the custom attributes for this assembly.

GetCustomAttributes(Type, Boolean) : Object[]

Gets the custom attributes for this assembly as specified by type.

GetCustomAttributesData() : IList<CustomAttributeData>

Returns information about the attributes that have been applied to the current Assembly, expressed as CustomAttributeData objects.

static
GetEntryAssembly() : Assembly

Gets the process executable in the default application domain. In other application domains, this is the first executable that was executed by AppDomain.ExecuteAssembly(String).

static
GetExecutingAssembly() : Assembly

Gets the assembly that contains the code that is currently executing.

GetExportedTypes() : Type[]

Gets the public types defined in this assembly that are visible outside the assembly.

GetFile(String) : FileStream

Gets a FileStream for the specified file in the file table of the manifest of this assembly.

GetFiles() : FileStream[]

Gets the files in the file table of an assembly manifest.

GetFiles(Boolean) : FileStream[]

Gets the files in the file table of an assembly manifest, specifying whether to include resource modules.

override
GetHashCode() : Int32

Returns the hash code for this instance.

GetLoadedModules() : Module[]

Gets all the loaded modules that are part of this assembly.

GetLoadedModules(Boolean) : Module[]

Gets all the loaded modules that are part of this assembly, specifying whether to include resource modules.

GetManifestResourceInfo(String) : ManifestResourceInfo

Returns information about how the given resource has been persisted.

GetManifestResourceNames() : String[]

Returns the names of all the resources in this assembly.

GetManifestResourceStream(String) : Stream

Loads the specified manifest resource from this assembly.

GetManifestResourceStream(Type, String) : Stream

Loads the specified manifest resource, scoped by the namespace of the specified type, from this assembly.

GetModule(String) : Module

Gets the specified module in this assembly.

GetModules() : Module[]

Gets all the modules that are part of this assembly.

GetModules(Boolean) : Module[]

Gets all the modules that are part of this assembly, specifying whether to include resource modules.

GetName() : AssemblyName

Gets an AssemblyName for this assembly.

GetName(Boolean) : AssemblyName

Gets an AssemblyName for this assembly, setting the codebase as specified by copiedName.

GetObjectData(SerializationInfo, StreamingContext)

Gets serialization information with all of the data needed to reinstantiate this assembly.

GetReferencedAssemblies() : AssemblyName[]

Gets the AssemblyName objects for all the assemblies referenced by this assembly.

GetSatelliteAssembly(CultureInfo) : Assembly

Gets the satellite assembly for the specified culture.

GetSatelliteAssembly(CultureInfo, Version) : Assembly

Gets the specified version of the satellite assembly for the specified culture.

GetType() : Type
GetType(String) : Type

Gets the Type object with the specified name in the assembly instance.

GetType(String, Boolean) : Type

Gets the Type object with the specified name in the assembly instance and optionally throws an exception if the type is not found.

GetType(String, Boolean, Boolean) : Type

Gets the Type object with the specified name in the assembly instance, with the options of ignoring the case, and of throwing an exception if the type is not found.

GetTypes() : Type[]

Gets the types defined in this assembly.

IsDefined(Type, Boolean) : Boolean

Indicates whether or not a specified attribute has been applied to the assembly.

static
Load(Byte[]) : Assembly

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the application domain of the caller.

static
Load(AssemblyName) : Assembly

Loads an assembly given its AssemblyName.

static
Load(String) : Assembly

Loads an assembly given the long form of its name.

static
Load(Byte[], Byte[]) : Assembly

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols for the assembly. The assembly is loaded into the application domain of the caller.

static
Load(AssemblyName, Evidence) : Assembly

Loads an assembly given its AssemblyName. The assembly is loaded into the domain of the caller using the supplied evidence.

static
Load(String, Evidence) : Assembly

Loads an assembly given its display name, loading the assembly into the domain of the caller using the supplied evidence.

static
Load(Byte[], Byte[], Evidence) : Assembly

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and evidence for the assembly. The assembly is loaded into the application domain of the caller.

static
Load(Byte[], Byte[], SecurityContextSource) : Assembly

Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols and specifying the source for the security context. The assembly is loaded into the application domain of the caller.

static
LoadFile(String) : Assembly

Loads the contents of an assembly file on the specified path.

static
LoadFile(String, Evidence) : Assembly

Loads an assembly given its path, loading the assembly into the domain of the caller using the supplied evidence.

static
LoadFrom(String) : Assembly

Loads an assembly given its file name or path.

static
LoadFrom(String, Evidence) : Assembly

Loads an assembly given its file name or path and supplying security evidence.

static
LoadFrom(String, Byte[], AssemblyHashAlgorithm) : Assembly

Loads an assembly given its file name or path, hash value, and hash algorithm.

static
LoadFrom(String, Evidence, Byte[], AssemblyHashAlgorithm) : Assembly

Loads an assembly given its file name or path, security evidence, hash value, and hash algorithm.

LoadModule(String, Byte[]) : Module

Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file.

LoadModule(String, Byte[], Byte[]) : Module

Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file. The raw bytes representing the symbols for the module are also loaded.

static
LoadWithPartialName(String) : Assembly

Loads an assembly from the application directory or from the global assembly cache using a partial name.

static
LoadWithPartialName(String, Evidence) : Assembly

Loads an assembly from the application directory or from the global assembly cache using a partial name. The assembly is loaded into the domain of the caller using the supplied evidence.

static
ReflectionOnlyLoad(Byte[]) : Assembly

Loads the assembly from a common object file format (COFF)-based image containing an emitted assembly. The assembly is loaded into the reflection-only context of the caller's application domain.

static
ReflectionOnlyLoad(String) : Assembly

Loads an assembly into the reflection-only context, given its display name.

static
ReflectionOnlyLoadFrom(String) : Assembly

Loads an assembly into the reflection-only context, given its path.

override
ToString() : String

Returns the full name of the assembly, also known as the display name.

static
UnsafeLoadFrom(String) : Assembly

Loads an assembly into the load-from context, bypassing some security checks.

Public Events

ModuleResolve

Occurs when the common language runtime class loader cannot resolve a reference to an internal module of an assembly through normal means.

Public Operators

static
Equality(Assembly, Assembly)

Indicates whether two Assembly objects are equal.

static
Inequality(Assembly, Assembly)

Indicates whether two Assembly objects are not equal.

Explicitly Implemented Interface Members

Assembly$_Assembly.GetType

Returns the type of the current instance.