Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Reflection.​Assembly
Assembly: System.Runtime
Inheritance: object → Assembly
Implemented Interfaces
Represents an assembly, which is a reusable, versionable, and self-describing building block of a common language runtime application.
Properties
public
string
CodeBase
Gets the location of the assembly as specified originally, for example, in an <see cref="T:System.Reflection.AssemblyName" /> object.
public
Collections.​Generic.​IEnumerable<​CustomAttributeData>
CustomAttributes
Gets a collection that contains this assembly's custom attributes.
public
Collections.​Generic.​IEnumerable<​TypeInfo>
DefinedTypes
Gets a collection of the types defined in this assembly.
public
MethodInfo
EntryPoint
Gets the entry point of this assembly.
public
string
EscapedCodeBase
Gets the URI, including escape characters, that represents the codebase.
public
Collections.​Generic.​IEnumerable<​Type>
ExportedTypes
Gets a collection of the public types defined in this assembly that are visible outside the assembly.
public
string
FullName
Gets the display name of the assembly.
public
bool
GlobalAssemblyCache
Gets a value indicating whether the assembly was loaded from the global assembly cache (.NET Framework only).
public
long
HostContext
Gets the host context with which the assembly was loaded.
public
string
ImageRuntimeVersion
Gets a string representing the version of the common language runtime (CLR) saved in the file containing the manifest.
public
bool
IsCollectible
Gets a value that indicates whether this assembly is held in a collectible <see cref="T:System.Runtime.Loader.AssemblyLoadContext" /> .
public
bool
IsDynamic
Gets a value that indicates whether the current assembly was generated dynamically in the current process by using reflection emit.
public
bool
IsFullyTrusted
Gets a value that indicates whether the current assembly is loaded with full trust.
public
string
Location
Gets the full path or UNC location of the loaded file that contains the manifest.
public
Module
ManifestModule
Gets the module that contains the manifest for the current assembly.
public
Collections.​Generic.​IEnumerable<​Module>
Modules
Gets a collection that contains the modules in this assembly.
public
bool
ReflectionOnly
Gets a <see cref="T:System.Boolean" /> value indicating whether this assembly was loaded into the reflection-only context.
SecurityRuleSet
Gets a value that indicates which set of security rules the common language runtime (CLR) enforces for this assembly.
Methods
public
object
CreateInstance​(string typeName)
Locates the specified type from this assembly and creates an instance of it using the system activator, using case-sensitive search.
Returns An instance of the specified type created with the parameterless constructor; or <see langword="null" /> if <paramref name="typeName" /> is not found. The type is resolved using the default binder, without specifying culture or activation attributes, and with <see cref="T:System.Reflection.BindingFlags" /> set to <see langword="Public" /> or <see langword="Instance" /> .
typeName
The <see cref="P:System.Type.FullName" /> of the type to locate.
public
object
CreateInstance​(string typeName,
bool ignoreCase)
Locates the specified type from this assembly and creates an instance of it using the system activator, with optional case-sensitive search.
Returns An instance of the specified type created with the parameterless constructor; or <see langword="null" /> if <paramref name="typeName" /> is not found. The type is resolved using the default binder, without specifying culture or activation attributes, and with <see cref="T:System.Reflection.BindingFlags" /> set to <see langword="Public" /> or <see langword="Instance" /> .
typeName
The <see cref="P:System.Type.FullName" /> of the type to locate.
ignoreCase
<see langword="true" /> to ignore the case of the type name; otherwise, <see langword="false" /> .
public
object
CreateInstance​(string typeName,
bool ignoreCase,
BindingFlags bindingAttr,
Binder binder,
object[] args,
Globalization.​CultureInfo culture,
object[] activationAttributes)
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.
Returns An instance of the specified type, or <see langword="null" /> if <paramref name="typeName" /> is not found. The supplied arguments are used to resolve the type, and to bind the constructor that is used to create the instance.
typeName
The <see cref="P:System.Type.FullName" /> of the type to locate.
ignoreCase
<see langword="true" /> to ignore the case of the type name; otherwise, <see langword="false" /> .
bindingAttr
A bitmask that affects the way in which the search is conducted. The value is a combination of bit flags from <see cref="T:System.Reflection.BindingFlags" /> .
binder
An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see langword="MemberInfo" /> objects via reflection. If <paramref name="binder" /> is <see langword="null" /> , the default binder is used.
args
An array that contains the arguments to be passed to the constructor. This array of arguments must match in number, order, and type the parameters of the constructor to be invoked. If the parameterless constructor is desired, <paramref name="args" /> must be an empty array or <see langword="null" /> .
culture
An instance of <see langword="CultureInfo" /> used to govern the coercion of types. If this is <see langword="null" /> , the <see cref="T:System.Globalization.CultureInfo" /> for the current thread is used. (This is necessary to convert a string that represents 1000 to a <see cref="T:System.Double" /> value, for example, since 1000 is represented differently by different cultures.)
activationAttributes
An array of one or more attributes that can participate in activation. Typically, an array that contains a single <see cref="T:System.Runtime.Remoting.Activation.UrlAttribute" /> object that specifies the URL that is required to activate a remote object. This parameter is related to client-activated objects. Client activation is a legacy technology that is retained for backward compatibility but is not recommended for new development. Distributed applications should instead use Windows Communication Foundation.
public static
string
CreateQualifiedName​(string assemblyName,
string typeName)
Creates the name of a type qualified by the display name of its assembly.
Returns The full name of the type qualified by the display name of the assembly.
assemblyName
The display name of an assembly.
typeName
The full name of a type.
public
bool
Equals​(object o)
Determines whether this assembly and the specified object are equal.
Returns <see langword="true" /> if <paramref name="o" /> is equal to this instance; otherwise, <see langword="false" /> .
o
The object to compare with this instance.
public static
Assembly
GetAssembly​(Type type)
Gets the currently loaded assembly in which the specified type is defined.
Returns The assembly in which the specified type is defined.
type
An object representing a type in the assembly that will be returned.
public static
Assembly
GetCallingAssembly​()
Returns the <see cref="T:System.Reflection.Assembly" /> of the method that invoked the currently executing method.
Returns The <see langword="Assembly" /> object of the method that invoked the currently executing method.
public
object[]
GetCustomAttributes​(bool inherit)
Gets all the custom attributes for this assembly.
Returns An array that contains the custom attributes for this assembly.
inherit
This argument is ignored for objects of type <see cref="T:System.Reflection.Assembly" /> .
public
object[]
GetCustomAttributes​(Type attributeType,
bool inherit)
Gets the custom attributes for this assembly as specified by type.
Returns An array that contains the custom attributes for this assembly as specified by <paramref name="attributeType" /> .
attributeType
The type for which the custom attributes are to be returned.
inherit
This argument is ignored for objects of type <see cref="T:System.Reflection.Assembly" /> .
public
Collections.​Generic.​IList<​CustomAttributeData>
GetCustomAttributesData​()
Returns information about the attributes that have been applied to the current <see cref="T:System.Reflection.Assembly" /> , expressed as <see cref="T:System.Reflection.CustomAttributeData" /> objects.
Returns A generic list of <see cref="T:System.Reflection.CustomAttributeData" /> objects representing data about the attributes that have been applied to the current assembly.
public static
Assembly
GetEntryAssembly​()
Gets the entry assembly for the running application.
Returns The entry assembly for the running application. Can return <see langword="null" /> when called from unmanaged code.
public static
Assembly
GetExecutingAssembly​()
Gets the assembly that contains the code that is currently executing.
Returns The assembly that contains the code that is currently executing.
public
Type[]
GetExportedTypes​()
Gets the public types defined in this assembly that are visible outside the assembly.
Returns An array that represents the types defined in this assembly that are visible outside the assembly.
GetFile​(string name)
Gets a <see cref="T:System.IO.FileStream" /> for the specified file in the file table of the manifest of this assembly.
Returns A stream that contains the specified file, or <see langword="null" /> if the file is not found.
name
The name of the specified file. Do not include the path to the file.
public
IO.​FileStream[]
GetFiles​()
Gets the files in the file table of an assembly manifest.
Returns An array of streams that contain the files.
public
IO.​FileStream[]
GetFiles​(bool getResourceModules)
Gets the files in the file table of an assembly manifest, specifying whether to include resource modules.
Returns An array of streams that contain the files.
getResourceModules
<see langword="true" /> to include resource modules; otherwise, <see langword="false" /> .
public
int
GetHashCode​()
Returns the hash code for this instance.
Returns A 32-bit signed integer hash code.
public
Module[]
GetLoadedModules​()
Gets all the loaded modules that are part of this assembly.
Returns An array of modules.
public
Module[]
GetLoadedModules​(bool getResourceModules)
Gets all the loaded modules that are part of this assembly, specifying whether to include resource modules.
Returns An array of modules.
getResourceModules
<see langword="true" /> to include resource modules; otherwise, <see langword="false" /> .
public
ManifestResourceInfo
GetManifestResourceInfo​(string resourceName)
Returns information about how the given resource has been persisted.
Returns An object that is populated with information about the resource's topology, or <see langword="null" /> if the resource is not found.
resourceName
The case-sensitive name of the resource.
public
string[]
GetManifestResourceNames​()
Returns the names of all the resources in this assembly.
Returns An array that contains the names of all the resources.
public
IO.​Stream
GetManifestResourceStream​(string name)
Loads the specified manifest resource from this assembly.
Returns The manifest resource; or <see langword="null" /> if no resources were specified during compilation or if the resource is not visible to the caller.
name
The case-sensitive name of the manifest resource being requested.
public
IO.​Stream
GetManifestResourceStream​(Type type,
string name)
Loads the specified manifest resource, scoped by the namespace of the specified type, from this assembly.
Returns The manifest resource; or <see langword="null" /> if no resources were specified during compilation or if the resource is not visible to the caller.
type
The type whose namespace is used to scope the manifest resource name.
name
The case-sensitive name of the manifest resource being requested.
Returns The module being requested, or <see langword="null" /> if the module is not found.
name
The name of the module being requested.
Returns An array of modules.
public
Module[]
GetModules​(bool getResourceModules)
Gets all the modules that are part of this assembly, specifying whether to include resource modules.
Returns An array of modules.
getResourceModules
<see langword="true" /> to include resource modules; otherwise, <see langword="false" /> .
public
AssemblyName
GetName​()
Gets an <see cref="T:System.Reflection.AssemblyName" /> for this assembly.
Returns An object that contains the fully parsed display name for this assembly.
public
AssemblyName
GetName​(bool copiedName)
Gets an <see cref="T:System.Reflection.AssemblyName" /> for this assembly, setting the codebase as specified by <paramref name="copiedName" /> .
Returns An object that contains the fully parsed display name for this assembly.
copiedName
<see langword="true" /> to set the <see cref="P:System.Reflection.Assembly.CodeBase" /> to the location of the assembly after it was shadow copied; <see langword="false" /> to set <see cref="P:System.Reflection.Assembly.CodeBase" /> to the original location.
public
void
GetObjectData​(Runtime.​Serialization.​SerializationInfo info,
Runtime.​Serialization.​StreamingContext context)
Gets serialization information with all of the data needed to reinstantiate this assembly.
info
The object to be populated with serialization information.
context
The destination context of the serialization.
public
AssemblyName[]
GetReferencedAssemblies​()
Gets the <see cref="T:System.Reflection.AssemblyName" /> objects for all the assemblies referenced by this assembly.
Returns An array that contains the fully parsed display names of all the assemblies referenced by this assembly.
public
Assembly
GetSatelliteAssembly​(Globalization.​CultureInfo culture)
Gets the satellite assembly for the specified culture.
Returns The specified satellite assembly.
culture
The specified culture.
public
Assembly
GetSatelliteAssembly​(Globalization.​CultureInfo culture,
Version? version)
Gets the specified version of the satellite assembly for the specified culture.
Returns The specified satellite assembly.
culture
The specified culture.
version
The version of the satellite assembly.
public
Type
GetType​(string name)
Gets the <see cref="T:System.Type" /> object with the specified name in the assembly instance.
Returns An object that represents the specified class, or <see langword="null" /> if the class is not found.
name
The full name of the type.
public
Type
GetType​(string name,
bool throwOnError)
Gets the <see cref="T:System.Type" /> object with the specified name in the assembly instance and optionally throws an exception if the type is not found.
Returns An object that represents the specified class.
name
The full name of the type.
throwOnError
<see langword="true" /> to throw an exception if the type is not found; <see langword="false" /> to return <see langword="null" /> .
public
Type
GetType​(string name,
bool throwOnError,
bool ignoreCase)
Gets the <see cref="T:System.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.
Returns An object that represents the specified class.
name
The full name of the type.
throwOnError
<see langword="true" /> to throw an exception if the type is not found; <see langword="false" /> to return <see langword="null" /> .
ignoreCase
<see langword="true" /> to ignore the case of the type name; otherwise, <see langword="false" /> .
Returns An array that contains all the types that are defined in this assembly.
public
bool
IsDefined​(Type attributeType,
bool inherit)
Indicates whether or not a specified attribute has been applied to the assembly.
Returns <see langword="true" /> if the attribute has been applied to the assembly; otherwise, <see langword="false" /> .
attributeType
The type of the attribute to be checked for this assembly.
inherit
This argument is ignored for objects of this type.
public static
Assembly
Load​(byte[] rawAssembly)
Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly.
Returns The loaded assembly.
rawAssembly
A byte array that is a COFF-based image containing an emitted assembly.
public static
Assembly
Load​(byte[] rawAssembly,
byte[] rawSymbolStore)
Loads the assembly with a common object file format (COFF)-based image containing an emitted assembly, optionally including symbols for the assembly.
Returns The loaded assembly.
rawAssembly
A byte array that is a COFF-based image containing an emitted assembly.
rawSymbolStore
A byte array that contains the raw bytes representing the symbols for the assembly.
public static
Assembly
Load​(AssemblyName assemblyRef)
Loads an assembly given its <see cref="T:System.Reflection.AssemblyName" /> .
Returns The loaded assembly.
assemblyRef
The object that describes the assembly to be loaded.
public static
Assembly
Load​(string assemblyString)
Loads an assembly with the specified name.
Returns The loaded assembly.
assemblyString
The long or short form of the assembly name.
public static
Assembly
LoadFile​(string path)
Loads the contents of an assembly file on the specified path.
Returns The loaded assembly.
path
The fully qualified path of the file to load.
public static
Assembly
LoadFrom​(string assemblyFile)
Loads an assembly given its file name or path.
Returns The loaded assembly.
assemblyFile
The name or path of the file that contains the manifest of the assembly.
public static
Assembly
LoadFrom​(string assemblyFile,
byte[] hashValue,
Configuration.​Assemblies.​AssemblyHashAlgorithm hashAlgorithm)
Loads an assembly given its file name or path, hash value, and hash algorithm.
Returns The loaded assembly.
assemblyFile
The name or path of the file that contains the manifest of the assembly.
hashValue
The value of the computed hash code.
hashAlgorithm
The hash algorithm used for hashing files and for generating the strong name.
public
Module
LoadModule​(string moduleName,
byte[] rawModule)
Loads the module, internal to this assembly, with a common object file format (COFF)-based image containing an emitted module, or a resource file.
Returns The loaded module.
moduleName
The name of the module. This string must correspond to a file name in this assembly's manifest.
rawModule
A byte array that is a COFF-based image containing an emitted module, or a resource.
public
Module
LoadModule​(string moduleName,
byte[] rawModule,
byte[] rawSymbolStore)
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.
Returns The loaded module.
moduleName
The name of the module. This string must correspond to a file name in this assembly's manifest.
rawModule
A byte array that is a COFF-based image containing an emitted module, or a resource.
rawSymbolStore
A byte array containing the raw bytes representing the symbols for the module. Must be <see langword="null" /> if this is a resource file.
public static
Assembly
LoadWithPartialName​(string partialName)
Loads an assembly from the application directory or from the global assembly cache using a partial name.
Returns The loaded assembly. If <paramref name="partialName" /> is not found, this method returns <see langword="null" /> .
partialName
The display name of the assembly.
public static
Assembly
ReflectionOnlyLoad​(byte[] rawAssembly)
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.
Returns The loaded assembly.
rawAssembly
A byte array that is a COFF-based image containing an emitted assembly.
public static
Assembly
ReflectionOnlyLoad​(string assemblyString)
Loads an assembly into the reflection-only context, given its display name.
Returns The loaded assembly.
assemblyString
The display name of the assembly, as returned by the <see cref="P:System.Reflection.AssemblyName.FullName" /> property.
public static
Assembly
ReflectionOnlyLoadFrom​(string assemblyFile)
Loads an assembly into the reflection-only context, given its path.
Returns The loaded assembly.
assemblyFile
The path of the file that contains the manifest of the assembly.
public static
void
SetEntryAssembly​(Assembly assembly)
Sets the application's entry assembly to the provided assembly object.
assembly
Assembly object that represents the application's new entry assembly.
public
string
ToString​()
Returns the full name of the assembly, also known as the display name.
Returns The full name of the assembly, or the class name if the full name of the assembly cannot be determined.
public static
Assembly
UnsafeLoadFrom​(string assemblyFile)
Loads an assembly into the load-from context, bypassing some security checks.
Returns The loaded assembly.
assemblyFile
The name or path of the file that contains the manifest of the assembly.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .