Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Clase AssemblyName

 

Publicado: octubre de 2016

Describe la identidad única de un ensamblado en su totalidad.

Espacio de nombres:   System.Reflection
Ensamblado:  mscorlib (en mscorlib.dll)

System.Object
  System.Reflection.AssemblyName

[SerializableAttribute]
[ClassInterfaceAttribute(ClassInterfaceType.None)]
[ComVisibleAttribute(true)]
public sealed class AssemblyName : _AssemblyName, ICloneable, 
	ISerializable, IDeserializationCallback

NombreDescripción
System_CAPS_pubmethodAssemblyName()

Inicializa una nueva instancia de la clase AssemblyName.

System_CAPS_pubmethodAssemblyName(String)

Inicializa una nueva instancia de la clase AssemblyName con el nombre para mostrar especificado.

NombreDescripción
System_CAPS_pubpropertyCodeBase

Obtiene o establece la ubicación del ensamblado como una dirección URL.

System_CAPS_pubpropertyContentType

Obtiene o establece un valor que indica el tipo de contenido que contiene el ensamblado.

System_CAPS_pubpropertyCultureInfo

Obtiene o establece la referencia cultural que admite el ensamblado.

System_CAPS_pubpropertyCultureName

Obtiene o establece el nombre de la referencia cultural asociada con el ensamblado.

System_CAPS_pubpropertyEscapedCodeBase

Obtiene el identificador URI, incluidos los caracteres de escape, que representa el código base.

System_CAPS_pubpropertyFlags

Obtiene o establece los atributos del ensamblado.

System_CAPS_pubpropertyFullName

Obtiene el nombre completo del ensamblado, también conocido como el nombre para mostrar.

System_CAPS_pubpropertyHashAlgorithm

Obtiene o establece el algoritmo hash utilizado por el manifiesto del ensamblado.

System_CAPS_pubpropertyKeyPair

Obtiene o establece el público y privado par de claves criptográficas que se utiliza para crear una firma de nombre seguro para el ensamblado.

System_CAPS_pubpropertyName

Obtiene o establece el nombre simple del ensamblado. Esto suele ser, aunque no necesariamente, el nombre de archivo del archivo de manifiesto del ensamblado, menos su extensión.

System_CAPS_pubpropertyProcessorArchitecture

Obtiene o establece un valor que identifica el procesador y los bits por palabra de la plataforma de destino mediante un archivo ejecutable.

System_CAPS_pubpropertyVersion

Obtiene o establece el principal, secundaria, compilación y números de revisión del ensamblado.

System_CAPS_pubpropertyVersionCompatibility

Obtiene o establece la información relacionada con la compatibilidad del ensamblado con otros ensamblados.

NombreDescripción
System_CAPS_pubmethodClone()

Realiza una copia de este AssemblyName objeto.

System_CAPS_pubmethodEquals(Object)

Determina si el objeto especificado es igual al objeto actual.(Heredado de Object).

System_CAPS_pubmethodSystem_CAPS_staticGetAssemblyName(String)

Obtiene el AssemblyName para un archivo determinado.

System_CAPS_pubmethodGetHashCode()

Sirve como la función hash predeterminada.(Heredado de Object).

System_CAPS_pubmethodGetObjectData(SerializationInfo, StreamingContext)

Obtiene información de serialización con todos los datos necesarios para volver a crear una instancia de este AssemblyName.

System_CAPS_pubmethodGetPublicKey()

Obtiene la clave pública del ensamblado.

System_CAPS_pubmethodGetPublicKeyToken()

Obtiene el token de clave pública, los últimos 8 bytes del hash SHA-1 de la clave pública con la que se firma la aplicación o el ensamblado.

System_CAPS_pubmethodGetType()

Obtiene el Type de la instancia actual.(Heredado de Object).

System_CAPS_pubmethodOnDeserialization(Object)

Implementa la interfaz ISerializable. El evento de deserialización vuelve a llamar a este método cuando se completa la deserialización.

System_CAPS_pubmethodSystem_CAPS_staticReferenceMatchesDefinition(AssemblyName, AssemblyName)

Devuelve un valor que indica si dos nombres de ensamblado son iguales. La comparación se basa en los nombres de ensamblado simple.

System_CAPS_pubmethodSetPublicKey(Byte[])

Establece la clave pública que identifica el ensamblado.

System_CAPS_pubmethodSetPublicKeyToken(Byte[])

Establece el token de clave pública, los últimos 8 bytes del hash SHA-1 de la clave pública con la que se firma la aplicación o el ensamblado.

System_CAPS_pubmethodToString()

Devuelve el nombre completo del ensamblado, también conocido como nombre para mostrar.(Invalida Object.ToString()).

NombreDescripción
System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.

System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName.GetTypeInfo(UInt32, UInt32, IntPtr)

Recupera la información de tipo de un objeto, que se puede usar después para obtener la información de tipo de una interfaz.

System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de tipo de información que suministra un objeto (0 ó 1)

System_CAPS_pubinterfaceSystem_CAPS_privmethod_AssemblyName.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.

The T:System.Reflection.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.

Delimiter

Meaning

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:

ContainingClass+NestedClass,MyAssembly

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

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

A fully specified T:System.Reflection.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 T:System.Version type.

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

To create a full strong name, create an T:System.Reflection.AssemblyName object using the default constructor and set the P:System.Reflection.AssemblyName.Name and P:System.Reflection.AssemblyName.KeyPair. The other properties are optional. Use M:System.Reflection.AssemblyName.SetPublicKey(System.Byte[]) and M:System.Reflection.AssemblyName.SetPublicKeyToken(System.Byte[]) to set the public key and the strong name. The strong name signing always uses the T:System.Security.Cryptography.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 Global Assembly Cache Tool (Gacutil.exe)

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

It is possible to specify a public key and a P:System.Reflection.AssemblyName.KeyPair with inconsistent values. This can be useful in developer scenarios. In this case, the public key retrieved with M:System.Reflection.AssemblyName.GetPublicKey specifies the correct public key, while the P:System.Reflection.AssemblyName.KeyPair specifies the public and private keys used during development. When the runtime detects a mismatch between the P:System.Reflection.AssemblyName.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 T:System.Reflection.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 T:System.Reflection.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 T:System.Reflection.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=1.0.0.0, Culture=en, PublicKeyToken=a5d015c7d5a0b012

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

using System;
using System.Reflection;

class Module1
{
    public static 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 = typeof(Module1).Assembly;
        Display(indent, "Assembly identity={0}", a.FullName);
        Display(indent+1, "Codebase={0}", a.CodeBase);

        // Display the set of assemblies our assemblies reference.

        Display(indent, "Referenced assemblies:");
        foreach (AssemblyName an in a.GetReferencedAssemblies() )
        {
             Display(indent + 1, "Name={0}, Version={1}, Culture={2}, PublicKey token={3}", an.Name, an.Version, an.CultureInfo.Name, (BitConverter.ToString (an.GetPublicKeyToken())));
        }
        Display(indent, "");

        // Display information about each assembly loading into this AppDomain.
        foreach (Assembly b in AppDomain.CurrentDomain.GetAssemblies())
        {
            Display(indent, "Assembly: {0}", b);

            // Display information about each module of this assembly.
            foreach ( Module m in b.GetModules(true) )
            {
                Display(indent+1, "Module: {0}", m.Name);
            }

            // Display information about each type exported from this assembly.

            indent += 1;
            foreach ( Type t in b.GetExportedTypes() )
            {
                Display(0, "");
                Display(indent, "Type: {0}", t);

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

                indent += 1;
                foreach (MemberInfo mi in t.GetMembers() )
                {
                    Display(indent, "Member: {0}", mi.Name);
                    DisplayAttributes(indent, mi);

                    // If the member is a method, display information about its parameters.

                    if (mi.MemberType==MemberTypes.Method)
                    {
                        foreach ( ParameterInfo pi in ((MethodInfo) mi).GetParameters() )
                        {
                            Display(indent+1, "Parameter: Type={0}, Name={1}", pi.ParameterType, pi.Name);
                        }
                    }

                    // If the member is a property, display information about the property's accessor methods.
                    if (mi.MemberType==MemberTypes.Property)
                    {
                        foreach ( MethodInfo am in ((PropertyInfo) mi).GetAccessors() )
                        {
                            Display(indent+1, "Accessor method: {0}", am);
                        }
                    }
                }
                indent -= 1;
            }
            indent -= 1;
        }
    }

    // Displays the custom attributes applied to the specified member.
    public static void DisplayAttributes(Int32 indent, MemberInfo mi)
    {
        // Get the set of custom attributes; if none exist, just return.
        object[] attrs = mi.GetCustomAttributes(false);
        if (attrs.Length==0) {return;}

        // Display the custom attributes applied to this member.
        Display(indent+1, "Attributes:");
        foreach ( object o in attrs )
        {
            Display(indent+2, "{0}", o.ToString());
        }
    }

    // Display a formatted string indented by the specified amount.
    public static void Display(Int32 indent, string format, params object[] param) 

    {
        Console.Write(new string(' ', indent*2));
        Console.WriteLine(format, param);
    }
}

//The output shown below is abbreviated.
//
//Assembly identity=ReflectionCS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
//  Codebase=file:///C:/Documents and Settings/test/My Documents/Visual Studio 2005/Projects/Reflection/Reflection/obj/Debug/Reflection.exe
//Referenced assemblies:
//  Name=mscorlib, Version=2.0.0.0, Culture=, PublicKey token=B7-7A-5C-56-19-34-E0-89
//
//Assembly: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//  Module: mscorlib.dll
//
//  Type: System.Object
//    Member: GetType
//    Member: ToString
//    Member: Equals
//      Parameter: Type=System.Object, Name=obj
//    Member: Equals
//      Parameter: Type=System.Object, Name=objA
//      Parameter: Type=System.Object, Name=objB
//    Member: ReferenceEquals
//      Attributes:
//        System.Runtime.ConstrainedExecution.ReliabilityContractAttribute
//      Parameter: Type=System.Object, Name=objA
//      Parameter: Type=System.Object, Name=objB
//    Member: GetHashCode
//    Member: .ctor
//      Attributes:
//        System.Runtime.ConstrainedExecution.ReliabilityContractAttribute
//
//  Type: System.ICloneable
//    Member: Clone
//
//  Type: System.Collections.IEnumerable
//    Member: GetEnumerator
//      Attributes:
//        System.Runtime.InteropServices.DispIdAttribute
//
//  Type: System.Collections.ICollection
//    Member: CopyTo
//      Parameter: Type=System.Array, Name=array
//      Parameter: Type=System.Int32, Name=index
//    Member: get_Count
//    Member: get_SyncRoot
//    Member: get_IsSynchronized
//    Member: Count
//      Accessor method: Int32 get_Count()
//    Member: SyncRoot
//      Accessor method: System.Object get_SyncRoot()
//    Member: IsSynchronized
//      Accessor method: Boolean get_IsSynchronized()
//
//  Type: System.Collections.IList
//    Member: get_Item
//      Parameter: Type=System.Int32, Name=index
//    Member: set_Item
//      Parameter: Type=System.Int32, Name=index
//      Parameter: Type=System.Object, Name=value
//    Member: Add
//      Parameter: Type=System.Object, Name=value
//    Member: Contains
//      Parameter: Type=System.Object, Name=value
//    Member: Clear
//    Member: get_IsReadOnly
//    Member: get_IsFixedSize
//    Member: IndexOf
//      Parameter: Type=System.Object, Name=value
//    Member: Insert
//      Parameter: Type=System.Int32, Name=index
//      Parameter: Type=System.Object, Name=value
//    Member: Remove
//      Parameter: Type=System.Object, Name=value
//    Member: RemoveAt
//      Parameter: Type=System.Int32, Name=index
//    Member: Item
//      Accessor method: System.Object get_Item(Int32)
//      Accessor method: Void set_Item(Int32, System.Object)
//    Member: IsReadOnly
//      Accessor method: Boolean get_IsReadOnly()
//    Member: IsFixedSize
//      Accessor method: Boolean get_IsFixedSize()
//
//  Type: System.Array
//    Member: IndexOf
//      Parameter: Type=T[], Name=array
//      Parameter: Type=T, Name=value
//    Member: AsReadOnly
//      Parameter: Type=T[], Name=array
//    Member: Resize
//      Attributes:
//        System.Runtime.ConstrainedExecution.ReliabilityContractAttribute
//      Parameter: Type=T[]&, Name=array
//      Parameter: Type=System.Int32, Name=newSize
//    Member: BinarySearch
//      Attributes:
//        System.Runtime.ConstrainedExecution.ReliabilityContractAttribute
//      Parameter: Type=T[], Name=array
//      Parameter: Type=T, Name=value
//    Member: BinarySearch
//      Attributes:
//        System.Runtime.ConstrainedExecution.ReliabilityContractAttribute
//      Parameter: Type=T[], Name=array
//      Parameter: Type=T, Name=value
//      Parameter: Type=System.Collections.Generic.IComparer`1[T], Name=comparer

Plataforma universal de Windows
Disponible desde 8
.NET Framework
Disponible desde 1.1
Biblioteca de clases portable
Se admite en: plataformas portátiles de .NET
Silverlight
Disponible desde 2.0
Windows Phone Silverlight
Disponible desde 7.0
Windows Phone
Disponible desde 8.1

Cualquier miembro ( Compartido en Visual Basic) estático público de este tipo es seguro para subprocesos. No se garantiza que los miembros de instancia sean seguros para subprocesos.

Volver al principio
Mostrar: