System.Reflection.Assembly Class

public class Assembly

Base Types

Object
  Assembly

Assembly

mscorlib

Library

RuntimeInfrastructure

Summary

Defines a Assembly , which is a reusable, versionable, and self-describing building block of an application.

Description

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:

[Note: For additional information about assemblies, see Partition II of the CLI Specification.]

See Also

System.Reflection Namespace

Members

Assembly Methods

Assembly.CreateInstance Method
Assembly.GetType Method
Assembly.GetTypes Method
Assembly.Load Method
Assembly.ToString Method

Assembly Properties

Assembly.FullName Property


Assembly.CreateInstance Method

public object CreateInstance(string typeName);

Summary

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

Parameters

typeName
The name of the type to locate.

Return Value

An instance of Object representing the type, with culture, arguments, and binding and activation attributes set to null , or null if typeName is not found.

Exceptions

Exception TypeCondition
ArgumentExceptiontypeName is the empty string ("") or "\0anything".
ArgumentNullExceptiontypeName is null .

See Also

System.Reflection.Assembly Class, System.Reflection Namespace

Assembly.GetType Method

public virtual Type GetType(string name);

Summary

Returns the Type object with the specified name defined in the current assembly.

Parameters

name
A String containing the name of the type defined in the current assembly.

Return Value

A Type object that represents the specified type, or null if the specified Type was not found.

Exceptions

Exception TypeCondition
ArgumentExceptionname is equal to System.String.Empty or starts with the null character ('\0').
ArgumentNullExceptionname is null .

Description

[Behaviors: As described above.]

See Also

System.Reflection.Assembly Class, System.Reflection Namespace

Assembly.GetTypes Method

public virtual Type[] GetTypes();

Summary

Returns the types defined in the current assembly.

Return Value

An array of type Type containing all of the types defined in the current assembly.

See Also

System.Reflection.Assembly Class, System.Reflection Namespace

Assembly.Load Method

public static Assembly Load(string assemblyString);

Summary

Loads the specified assembly.

Parameters

assemblyString
A String containing the name of the assembly.

Return Value

The loaded Assembly .

Exceptions

Exception TypeCondition
ArgumentNullExceptionassemblyString is null .
ArgumentExceptionassemblyString is equal to System.String.Empty or starts with the null character ('\0').
FileNotFoundExceptionThe Assembly identified by assemblyString was not found.
BadImageFormatExceptionThe Assembly identified by assemblyString is not a valid assembly.

See Also

System.Reflection.Assembly Class, System.Reflection Namespace

Assembly.ToString Method

public override string ToString();

Summary

Returns a String representation of the value of the current instance.

Return Value

A String representation of the current instance. The string takes into account the current system culture.

Description

This method returns the System.Reflection.Assembly.FullName of the current assembly.

[Note: This method overrides System.Object.ToString .]

Example

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

See Also

System.Reflection.Assembly Class, System.Reflection Namespace

Assembly.FullName Property

public virtual string FullName { get; }

Summary

Gets the full name of the assembly.

Property Value

A String containing the full name of the assembly.

Description

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.]

Example

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

See Also

System.Reflection.Assembly Class, System.Reflection Namespace