public class Assembly
Object
Assembly
mscorlib
RuntimeInfrastructure
Defines a Assembly , which is a reusable, versionable, and self-describing building block of an application.
An assembly is a reusable, versionable, self-describing deployment unit for types and resources. Assemblies are the fundamental units of deployment, and consist of collections of types and resources that are built to work together and form logical units of functionality.An assembly consists of the following two logical elements:
The following information is captured in an assembly manifest:
- The sets of types and resources that form some logical unit of functionality.
- A manifest, which is the metadata that describes how the types and resources of an assembly relate and what they depend on to work properly.
[Note: For additional information about assemblies, see Partition II of the CLI Specification.]
Identity.
An assembly's identity includes its simple name (also called its weak name), a version number, an optional culture if the assembly contains localized resources, and an optional public key used to guarantee name uniqueness and to "protect" the name from unwanted reuse.Contents.
Assemblies contain types and resources. The manifest lists the names of all the types and resources that are visible outside the assembly, along with information about where they can be found within the assembly.Dependencies.
Each assembly explicitly describes other assemblies that it is dependent upon. Included in this dependency information is the version of each dependency that was present when the manifest was built and tested. In this way the "known good" configuration is recorded and can be reverted to in case of failures due to version mismatches.Requested Permissions.
As an assembly is being built, the assembly records the set of permissions that the assembly requires to run.
System.Reflection Namespace
Assembly Methods
Assembly.CreateInstance Method
Assembly.GetType Method
Assembly.GetTypes Method
Assembly.Load Method
Assembly.ToString Method
Assembly Properties
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.
- typeName
- The name of the type to locate.
An instance ofObject
representing the type, with culture, arguments, and binding and activation attributes set tonull
, ornull
if typeName is not found.
Exception Type Condition ArgumentException typeName is the empty string ("") or "\0anything". ArgumentNullException typeName is null
.
System.Reflection.Assembly Class, System.Reflection Namespace
public virtual Type GetType(string name);
Returns the Type object with the specified name defined in the current assembly.
- name
- A String containing the name of the type defined in the current assembly.
A Type object that represents the specified type, ornull
if the specified Type was not found.
Exception Type Condition ArgumentException name is equal to System.String.Empty or starts with the null character ('\0'). ArgumentNullException name is null
.
[Behaviors: As described above.]
System.Reflection.Assembly Class, System.Reflection Namespace
public virtual Type[] GetTypes();
Returns the types defined in the current assembly.
An array of type Type containing all of the types defined in the current assembly.
System.Reflection.Assembly Class, System.Reflection Namespace
public static Assembly Load(string assemblyString);
Loads the specified assembly.
- assemblyString
- A String containing the name of the assembly.
The loaded Assembly .
Exception Type Condition ArgumentNullException assemblyString is null
.ArgumentException assemblyString is equal to System.String.Empty or starts with the null character ('\0'). FileNotFoundException The Assembly identified by assemblyString was not found. BadImageFormatException The Assembly identified by assemblyString is not a valid assembly.
System.Reflection.Assembly Class, System.Reflection Namespace
public override string ToString();
Returns a String representation of the value of the current instance.
A String representation of the current instance. The string takes into account the current system culture.
This method returns the System.Reflection.Assembly.FullName of the current assembly.[Note: This method overrides System.Object.ToString .]
The following example demonstrates the use of the System.Reflection.Assembly.ToString method in an assembly compiled into a file named "HelloWorld".
using System; using System.Reflection; public class AssemblyExample { public static void Main() { Assembly a = Assembly.Load("helloworld"); Console.WriteLine(a.ToString()); } }The output is
HelloWorld, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
System.Reflection.Assembly Class, System.Reflection Namespace
public virtual string FullName { get; }
Gets the full name of the assembly.
A String containing the full name of the assembly.
This property is read-only.[Behaviors: As described above.]
[Default: The full name is returned in the following format:
<assemblyTextualName>, Version=<major.minor.build.revision>, Culture=neutral, PublicKeyToken=<publicKeyToken>
[Note: The <assemblyTextualName> section of the string contains the textual name of the assembly, and is equivalent to the name of the file into which the assembly manifest is compiled. This name does not change even if the file with the assembly manifest is later renamed. For additional information about assembly manifests, see Partition II of the CLI Specification.
For information on the Version information in the full name of a Assembly, see Version.
The <publicKeyToken> is a String containing the value of the public key token in hexadecimal format. A
null
publicKeyToken indicates that the current assembly is private. For additional information about public keys and public key tokens, see Partition II of the CLI Specification.]
]
[Usage: This property is used by the System.Reflection.Assembly.ToString method.]
The following example demonstrates using the System.Reflection.Assembly.FullName property to get the full name of an assembly compiled into a file named "HelloWorld".
using System; using System.Reflection; public class AssemblyExample { public static void Main() { Assembly a = Assembly.Load("helloworld"); Console.WriteLine(a.FullName); } }The output is
HelloWorld, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
System.Reflection.Assembly Class, System.Reflection Namespace