AssemblyName Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Describes an assembly's unique identity in full.

Namespace:   System.Reflection
Assembly:  mscorlib (in mscorlib.dll)


public ref class AssemblyName sealed : _AssemblyName, ICloneable, 
	ISerializable, IDeserializationCallback


Initializes a new instance of the AssemblyName class.


Initializes a new instance of the AssemblyName class with the specified display name.


Gets or sets the location of the assembly as a URL.


Gets or sets a value that indicates what type of content the assembly contains.


Gets or sets the culture supported by the assembly.


Gets or sets the name of the culture associated with the assembly.


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


Gets or sets the attributes of the assembly.


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


Gets or sets the hash algorithm used by the assembly manifest.


Gets or sets the public and private cryptographic key pair that is used to create a strong name signature for the assembly.


Gets or sets the simple name of the assembly. This is usually, but not necessarily, the file name of the manifest file of the assembly, minus its extension.


Gets or sets a value that identifies the processor and bits-per-word of the platform targeted by an executable.


Gets or sets the major, minor, build, and revision numbers of the assembly.


Gets or sets the information related to the assembly's compatibility with other assemblies.


Makes a copy of this AssemblyName object.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Gets the AssemblyName for a given file.


Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetObjectData(SerializationInfo^, StreamingContext)

Gets serialization information with all the data needed to recreate an instance of this AssemblyName.


Gets the public key of the assembly.


Gets the public key token, which is the last 8 bytes of the SHA-1 hash of the public key under which the application or assembly is signed.


Gets the Type of the current instance.(Inherited from Object.)


Implements the ISerializable interface and is called back by the deserialization event when deserialization is complete.

System_CAPS_pubmethodSystem_CAPS_staticReferenceMatchesDefinition(AssemblyName^, AssemblyName^)

Returns a value indicating whether two assembly names are the same. The comparison is based on the simple assembly names.


Sets the public key identifying the assembly.


Sets the public key token, which is the last 8 bytes of the SHA-1 hash of the public key under which the application or assembly is signed.


Returns the full name of the assembly, also known as the display name.(Overrides Object::ToString().)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName::GetIDsOfNames(Guid%, IntPtr, UInt32, UInt32, IntPtr)

Maps a set of names to a corresponding set of dispatch identifiers.

System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName::GetTypeInfo(UInt32, UInt32, IntPtr)

Retrieves the type information for an object, which can then be used to get the type information for an interface.


Retrieves the number of type information interfaces that an object provides (either 0 or 1).

System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName::Invoke(UInt32, Guid%, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Provides access to properties and methods exposed by an object.

The AssemblyName object contains information about an assembly, which you can use to bind to that assembly. An assembly's identity consists of the following:

  • Simple name.

  • Version number.

  • Cryptographic key pair.

  • Supported culture.

The simple name is typically the file name for the manifest file without its extension. The key pair includes a public and private key, used to create strong-name signatures for assemblies.

All compilers that support the common language runtime will emit the simple name of a nested class, and reflection constructs a mangled name when queried, in accordance with the following conventions.



Backslash (\)

Escape character.

Comma (,)

Precedes the assembly name.

Plus sign (+)

Precedes a nested class.

For example, the fully qualified name for a class might look like this:


A "++" becomes "\+\+", and a "\" becomes "\\".

This qualified name can be persisted and later used to load the Type. To search for and load a Type, use GetType either with the type name only or with the assembly qualified type name. GetType with the type name only will look for the Type in the caller's assembly and then in the System assembly. GetType with the assembly qualified type name will look for the Type in any assembly.

A fully specified AssemblyName must have the name, culture, public key or public key token, major version, minor version, build number, and revision number parameters. The last four are packaged in the Version type.

To create a simple name, create an AssemblyName object using the default constructor and set the Name. The other properties are optional.

To create a full strong name, create an AssemblyName object using the default constructor and set the Name and KeyPair. The other properties are optional. Use SetPublicKey and SetPublicKeyToken to set the public key and the strong name. The strong name signing always uses the SHA1 hash algorithm.

To ensure that the names are constructed correctly, use the following properties:

You can also get the name by using the /l option with the Gacutil.exe (Global Assembly Cache Tool)

For a partially specified strong name, create an AssemblyName object using the default constructor and set the name and public key. An assembly created using such an AssemblyName can be signed later using the Assembly Linker (Al.exe).

It is possible to specify a public key and a KeyPair with inconsistent values. This can be useful in developer scenarios. In this case, the public key retrieved with GetPublicKey specifies the correct public key, while the KeyPair specifies the public and private keys used during development. When the runtime detects a mismatch between the KeyPair and the public key, it looks up in the registry the correct key that matches the public key.

The format of the display name of an AssemblyName is a comma-delimited Unicode string that begins with the name, as follows:

Name <,Culture = CultureInfo> <,Version = Major.Minor.Build.Revision> <, StrongName> <,PublicKeyToken> '\0'

Name is the textual name of the assembly. CultureInfo is the RFC1766-format-defined culture. Major, Minor, Build, and Revision are the major version, minor version, build number, and revision number of the assembly. StrongName is the hexadecimal-encoded low-order 64 bits of the hash value of the public key generated using the SHA-1 hashing algorithm and the public key specified by SetPublicKey. PublicKeyToken is the hexadecimal-encoded public key specified by SetPublicKey.

Hexadecimal encoding is defined as the conversion of each byte of a binary object to two hexadecimal characters, progressing from least to most significant byte. Additional display values will be added as deemed necessary.

If the full public key is known, then PublicKey may be substituted for StrongName.

Also note that except for Name, which must come first, the lexical order of parameters is unimportant. However, any parameter (Version, Culture, StrongName or PublicKey) not specifically set is considered to be omitted, and the AssemblyName is then considered partial. When specifying partial information, Name parameters must be specified in the order described above.

When supplying a display name, the convention StrongName =null or PublicKey= null indicates that binding and matching against a simply named assembly is required. Additionally, the convention Culture= "" (double quote representing an empty string) indicates matching against the default culture.

The following example shows an AssemblyName for a simply named assembly with default culture.

ExampleAssembly, Culture=""

The following example shows a fully specified reference for a strongly named assembly with culture "en".

ExampleAssembly, Version=, Culture=en, PublicKeyToken=a5d015c7d5a0b012

This example shows how to use various reflection classes to analyze the metadata contained in an assembly.

using namespace System;
using namespace System::Reflection;

static void Display(Int32 indent, String^ format, ... array<Object^>^param) 
    Console::Write("{0}", gcnew String (' ', indent));
    Console::WriteLine(format, param);

// Displays the custom attributes applied to the specified member.
static void DisplayAttributes(Int32 indent, MemberInfo^ mi)
    // Get the set of custom attributes; if none exist, just return.
    array<Object^>^attrs = mi->GetCustomAttributes(false);

    if (attrs->Length==0)

    // Display the custom attributes applied to this member.
    Display(indent+1, "Attributes:");
    for each ( Object^ o in attrs )
        Display(indent*2, "{0}", o);

void main()
        // This variable holds the amount of indenting that 
        // should be used when displaying each line of information.
        Int32 indent = 0; 
        // Display information about the EXE assembly.
        Assembly^ a = System::Reflection::Assembly::GetExecutingAssembly();

        Display(indent, "Assembly identity={0}", gcnew array<Object^> {a->FullName});
        Display(indent+1, "Codebase={0}", gcnew array<Object^> {a->CodeBase});

        // Display the set of assemblies our assemblies reference.

        Display(indent, "Referenced assemblies:"); 

        for each ( AssemblyName^ an in a->GetReferencedAssemblies() )
            Display(indent + 1, "Name={0}, Version={1}, Culture={2}, PublicKey token={3}", gcnew array<Object^> {an->Name, an->Version, an->CultureInfo, (BitConverter::ToString(an->GetPublicKeyToken()))});
        Display(indent, "");  
        // Display information about each assembly loading into this AppDomain. 
        for each ( Assembly^ b in AppDomain::CurrentDomain->GetAssemblies()) 
            Display(indent, "Assembly: {0}", gcnew array<Object^> {b});
            // Display information about each module of this assembly.

            for each ( Module^ m in b->GetModules(true) ) 
                Display(indent+1, "Module: {0}", gcnew array<Object^> {m->Name});
            // Display information about each type exported from this assembly.

            indent += 1; 
            for each ( Type^ t in b->GetExportedTypes() ) 
                Display(0, "");  
                Display(indent, "Type: {0}", gcnew array<Object^> {t}); 

                // For each type, show its members & their custom attributes.

                indent += 1; 
                for each (MemberInfo^ mi in t->GetMembers() )
                    Display(indent, "Member: {0}", gcnew array<Object^> {mi->Name}); 
                    DisplayAttributes(indent, mi);

                    // If the member is a method, display information about its parameters.         
                    if (mi->MemberType==MemberTypes::Method) 

                        for each ( ParameterInfo^ pi in (((MethodInfo^) mi)->GetParameters()))
                            Display(indent+1, "Parameter: Type={0}, Name={1}", gcnew array<Object^> {pi->ParameterType, pi->Name}); 

                    // If the member is a property, display information about the property's accessor methods.
                    if (mi->MemberType==MemberTypes::Property) 
                        for each ( MethodInfo^ am in (((PropertyInfo^) mi)->GetAccessors()) )
                            Display(indent+1, "Accessor method: {0}", gcnew array<Object^> {am});
                // Display a formatted string indented by the specified amount.               
                indent -= 1;
            indent -= 1;
    catch (Exception^ e)

// The output shown below is abbreviated.
//Assembly identity=Reflection, Version=, Culture=neutral, PublicKeyToken=null
//  Codebase=file:///C:/Reflection.exe
//Referenced assemblies:
//  Name=mscorlib, Version=1.0.5000.0, Culture=, PublicKey token=B7-7A-5C-56-19-34-E0-89
//  Name=Microsoft.VisualBasic, Version=7.0.5000.0, Culture=, PublicKey token=B0-3F-5F-7F-11-D5-0A-3A
//Assembly: mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//  Module: mscorlib.dll
//  Module: prc.nlp
//  Module: prcp.nlp
//  Module: ksc.nlp
//  Module: ctype.nlp
//  Module: xjis.nlp
//  Module: bopomofo.nlp
//  Module: culture.nlp
//  Module: region.nlp
//  Module: sortkey.nlp
//  Module: charinfo.nlp
//  Module: big5.nlp
//  Module: sorttbls.nlp
//  Module: l_intl.nlp
//  Module: l_except.nlp
//  Type: System.Object
//    Member: GetHashCode
//    Member: Equals
//      Parameter: Type=System.Object, Name=obj
//    Member: ToString
//    Member: Equals
//      Parameter: Type=System.Object, Name=objA
//      Parameter: Type=System.Object, Name=objB
//    Member: ReferenceEquals
//      Parameter: Type=System.Object, Name=objA
//      Parameter: Type=System.Object, Name=objB
//    Member: GetType
//    Member: .ctor
//  Type: System.ICloneable
//    Member: Clone
//  Type: System.Collections.IEnumerable
//    Member: GetEnumerator
//      Attributes:
//        System.Runtime.InteropServices.DispIdAttribute
//  Type: System.Collections.ICollection
//    Member: get_IsSynchronized
//    Member: get_SyncRoot
//    Member: get_Count
//    Member: CopyTo
//      Parameter: Type=System.Array, Name=array
//      Parameter: Type=System.Int32, Name=index
//    Member: Count
//      Accessor method: Int32 get_Count()
//    Member: SyncRoot
//      Accessor method: System.Object get_SyncRoot()
//    Member: IsSynchronized
//      Accessor method: Boolean get_IsSynchronized()

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top