AssemblyName AssemblyName AssemblyName AssemblyName Class

Definición

Describe la identidad única de un ensamblado en su totalidad.Describes an assembly's unique identity in full.

public ref class AssemblyName sealed : ICloneable, System::Runtime::InteropServices::_AssemblyName, System::Runtime::Serialization::IDeserializationCallback, System::Runtime::Serialization::ISerializable
[System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class AssemblyName : ICloneable, System.Runtime.InteropServices._AssemblyName, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable
type AssemblyName = class
    interface ICloneable
    interface ISerializable
    interface IDeserializationCallback
    interface _AssemblyName
Public NotInheritable Class AssemblyName
Implements _AssemblyName, ICloneable, IDeserializationCallback, ISerializable
Herencia
AssemblyNameAssemblyNameAssemblyNameAssemblyName
Atributos
Implementaciones

Ejemplos

En este ejemplo se muestra cómo usar varias clases de reflexión para analizar los metadatos contenidos en un ensamblado.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)
    {
        return;          
    }
        
    // 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()
{
    try
    {
        // 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)
    {
        Console::WriteLine(e->Message);
    }
}

// The output shown below is abbreviated.
//
//Assembly identity=Reflection, Version=0.0.0.0, 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()
//
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
Imports System.Reflection

Module Module1
    Sub Main()
        ' This variable holds the amount of indenting that 
        ' should be used when displaying each line of information.
        Dim indent As Int32 = 0
        ' Display information about the EXE assembly.
        Dim a As Assembly = GetType(Module1).Assembly
        Display(indent, "Assembly identity={0}", a.FullName)
        Display(indent + 1, "Codebase={0}", a.CodeBase)

        ' Display the set of assemblies our assemblies reference.
        Dim an As AssemblyName
        Display(indent, "Referenced assemblies:")
        For Each 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))
        Next
        Display(indent, "")

        ' Display information about each assembly loading into this AppDomain.
        For Each a In AppDomain.CurrentDomain.GetAssemblies()
            Display(indent, "Assembly: {0}", a)

            ' Display information about each module of this assembly.
            Dim m As [Module]
            For Each m In a.GetModules(True)
                Display(indent + 1, "Module: {0}", m.Name)
            Next

            ' Display information about each type exported from this assembly.
            Dim t As Type
            indent += 1
            For Each t In a.GetExportedTypes()
                Display(0, "")
                Display(indent, "Type: {0}", t)

                ' For each type, show its members & their custom attributes.
                Dim mi As MemberInfo
                indent += 1
                For Each mi In t.GetMembers()
                    Display(indent, "Member: {0}", mi.Name)
                    DisplayAttributes(indent, mi)

                    ' If the member is a method, display information about its parameters.
                    Dim pi As ParameterInfo
                    If mi.MemberType = MemberTypes.Method Then
                        For Each pi In CType(mi, MethodInfo).GetParameters()
                            Display(indent + 1, "Parameter: Type={0}, Name={1}", pi.ParameterType, pi.Name)
                        Next
                    End If

                    ' If the member is a property, display information about the property's accessor methods.
                    If mi.MemberType = MemberTypes.Property Then
                        Dim am As MethodInfo
                        For Each am In CType(mi, PropertyInfo).GetAccessors()
                            Display(indent + 1, "Accessor method: {0}", am)
                        Next
                    End If
                Next
                indent -= 1
            Next
            indent -= 1
        Next
    End Sub

    ' Displays the custom attributes applied to the specified member.
    Sub DisplayAttributes(ByVal indent As Int32, ByVal mi As MemberInfo)
        ' Get the set of custom attributes; if none exist, just return.
        Dim attrs() As Object = mi.GetCustomAttributes(False)
        If attrs.Length = 0 Then Return

        ' Display the custom attributes applied to this member.
        Display(indent + 1, "Attributes:")
        Dim o As Object
        For Each o In attrs
            Display(indent + 2, "{0}", o.ToString())
        Next
    End Sub

    ' Display a formatted string indented by the specified amount.
    Sub Display(ByVal indent As Int32, ByVal format As String, ByVal ParamArray params() As Object)
        Console.Write(New String(" "c, indent * 2))
        Console.WriteLine(format, params)
    End Sub
End Module

'The output shown below is abbreviated.
'
'Assembly identity=Reflection, Version=0.0.0.0, 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()
'

Comentarios

El AssemblyName objeto contiene información sobre un ensamblado, que se puede utilizar para enlazar a ese ensamblado.The AssemblyName object contains information about an assembly, which you can use to bind to that assembly. La identidad de un ensamblado consta de lo siguiente:An assembly's identity consists of the following:

  • Nombre simple.Simple name.

  • Número de versión.Version number.

  • Par de claves criptográficas.Cryptographic key pair.

  • Referencia cultural admitida.Supported culture.

El nombre simple suele ser el nombre de archivo del archivo de manifiesto sin su extensión.The simple name is typically the file name for the manifest file without its extension. El par de claves incluye una clave pública y privada, que se usa para crear firmas de nombre seguro para los ensamblados.The key pair includes a public and private key, used to create strong-name signatures for assemblies.

Todos los compiladores que admiten la Common Language Runtime emitirán el nombre simple de una clase anidada y la reflexión construirá un nombre alterado cuando se realice la consulta, de acuerdo con las convenciones siguientes.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.

delimitadorDelimiter SignificadoMeaning
Barra diagonal inversa (\)Backslash (\) Carácter de escape.Escape character.
Coma (,)Comma (,) Precede al nombre del ensamblado.Precedes the assembly name.
Signo más (+)Plus sign (+) Precede a una clase anidada.Precedes a nested class.

Por ejemplo, el nombre completo de una clase podría tener el siguiente aspecto:For example, the fully qualified name for a class might look like this:

ContainingClass + NestedClass, myAssemblyContainingClass+NestedClass,MyAssembly

Un "+ +" se convierte\en "\+\+" y "\" se convierte en "\".A "++" becomes "\+\+", and a "\" becomes "\\".

Este nombre completo puede conservarse y, posteriormente, usarse para Typecargar.This qualified name can be persisted and later used to load the Type. Para buscar y cargar un Type, use GetType con el nombre de tipo solamente o con el nombre de tipo calificado con el ensamblado.To search for and load a Type, use GetType either with the type name only or with the assembly qualified type name. GetTypecon el nombre de tipo solo Type buscará en el ensamblado del llamador y, a continuación, en el ensamblado del sistema.GetType with the type name only will look for the Type in the caller's assembly and then in the System assembly. GetTypecon el nombre de tipo calificado con el ensamblado Type , buscará en cualquier ensamblado.GetType with the assembly qualified type name will look for the Type in any assembly.

Un valor completo AssemblyName de especificado debe tener los parámetros nombre, referencia cultural, clave pública o token de clave pública, versión principal, versión secundaria, número de compilación y número de revisión.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. Los cuatro últimos se empaquetan en el Version tipo.The last four are packaged in the Version type.

Para crear un nombre simple, cree un AssemblyName objeto con el constructor sin parámetros y Nameestablezca.To create a simple name, create an AssemblyName object using the parameterless constructor and set the Name. Las demás propiedades son opcionales.The other properties are optional.

Para crear un nombre seguro completo, cree un AssemblyName objeto con el constructor sin parámetros y Name establezca y KeyPair.To create a full strong name, create an AssemblyName object using the parameterless constructor and set the Name and KeyPair. Las demás propiedades son opcionales.The other properties are optional. Utilice SetPublicKey ySetPublicKeyToken para establecer la clave pública y el nombre seguro.Use SetPublicKey and SetPublicKeyToken to set the public key and the strong name. La firma de nombre seguro siempre usa SHA1 el algoritmo hash.The strong name signing always uses the SHA1 hash algorithm.

Para asegurarse de que los nombres se construyen correctamente, use las siguientes propiedades:To ensure that the names are constructed correctly, use the following properties:

También puede obtener el nombre mediante la /l opción con Gacutil. exe (herramienta de caché global de ensamblados)You can also get the name by using the /l option with the Gacutil.exe (Global Assembly Cache Tool)

Para un nombre seguro parcialmente especificado, cree un AssemblyName objeto con el constructor sin parámetros y establezca el nombre y la clave pública.For a partially specified strong name, create an AssemblyName object using the parameterless constructor and set the name and public key. Un ensamblado creado mediante este AssemblyName tipo de se puede firmar más adelante mediante Assembly Linker (al. exe).An assembly created using such an AssemblyName can be signed later using the Assembly Linker (Al.exe).

Es posible especificar una clave pública y una KeyPair con valores incoherentes.It is possible to specify a public key and a KeyPair with inconsistent values. Esto puede ser útil en escenarios de desarrollador.This can be useful in developer scenarios. En este caso, la clave pública recuperada GetPublicKey con especifica la clave pública correcta, mientras KeyPair que especifica las claves públicas y privadas que se usan durante el desarrollo.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. Cuando el tiempo de ejecución detecta una desigualdad KeyPair entre y la clave pública, busca en el registro la clave correcta que coincide con la clave pública.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.

El formato del nombre para mostrar de un AssemblyName es una cadena Unicode separada por comas que comienza con el nombre, como se indica a continuación: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'

Namees el nombre textual del ensamblado.Name is the textual name of the assembly. CultureInfoes la referencia cultural del formato RFC1766.CultureInfo is the RFC1766-format-defined culture. Major, Minor, Build yRevision son la versión principal, la versión secundaria, el número de compilación y el número de revisión del ensamblado.Major, Minor, Build, and Revision are the major version, minor version, build number, and revision number of the assembly. StrongNamees los bits 64 de orden inferior con codificación hexadecimal del valor hash de la clave pública generada mediante el algoritmo hash SHA-1 y la clave pública especificada por SetPublicKey.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. PublicKeyTokenes la clave pública codificada en hexadecimal especificada por SetPublicKey.PublicKeyToken is the hexadecimal-encoded public key specified by SetPublicKey.

La codificación hexadecimal se define como la conversión de cada byte de un objeto binario en dos caracteres hexadecimales, lo que progresa desde menos hasta el byte más significativo.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. Se agregarán valores de presentación adicionales según sea necesario.Additional display values will be added as deemed necessary.

Si se conoce la clave pública completa, PublicKey se puede sustituir por StrongName.If the full public key is known, then PublicKey may be substituted for StrongName.

Tenga en cuenta también que Name, a excepción de, que debe aparecer en primer lugar, el orden léxico de los parámetros no es importante.Also note that except for Name, which must come first, the lexical order of parameters is unimportant. Sin embargo, se consideraVersionque Culturecualquier StrongName parámetro PublicKey(, o) AssemblyName no establecido específicamente se omite y, a continuación, se considera parcial.However, any parameter (Version, Culture, StrongName or PublicKey) not specifically set is considered to be omitted, and the AssemblyName is then considered partial. Al especificar la información parcial, los parámetros de nombre deben especificarse en el orden descrito anteriormente.When specifying partial information, Name parameters must be specified in the order described above.

Al proporcionar un nombre para mostrar, la StrongName =null Convención PublicKey= null o indica que se requiere el enlace y la coincidencia con un ensamblado con nombre simple.When supplying a display name, the convention StrongName =null or PublicKey= null indicates that binding and matching against a simply named assembly is required. Además, la Convención Culture= "" (comilla doble que representa una cadena vacía) indica la coincidencia con la referencia cultural predeterminada.Additionally, the convention Culture= "" (double quote representing an empty string) indicates matching against the default culture.

En el ejemplo siguiente se AssemblyName muestra una para un ensamblado con nombre simple con la referencia cultural predeterminada.The following example shows an AssemblyName for a simply named assembly with default culture.

ExampleAssembly, Culture=""  

En el ejemplo siguiente se muestra una referencia completa para un ensamblado con nombre seguro con la referencia cultural "en".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  

Constructores

AssemblyName() AssemblyName() AssemblyName() AssemblyName()

Inicializa una nueva instancia de la clase AssemblyName.Initializes a new instance of the AssemblyName class.

AssemblyName(String) AssemblyName(String) AssemblyName(String) AssemblyName(String)

Inicializa una nueva instancia de la clase AssemblyName con el nombre para mostrar especificado.Initializes a new instance of the AssemblyName class with the specified display name.

Propiedades

CodeBase CodeBase CodeBase CodeBase

Indica o establece la ubicación del ensamblado como una dirección URL.Gets or sets the location of the assembly as a URL.

ContentType ContentType ContentType ContentType

Obtiene o establece un valor que indica el tipo del contenido del ensamblado.Gets or sets a value that indicates what type of content the assembly contains.

CultureInfo CultureInfo CultureInfo CultureInfo

Indica o establece la referencia cultural que admite el ensamblado.Gets or sets the culture supported by the assembly.

CultureName CultureName CultureName CultureName

Obtiene o establece el nombre de la referencia cultural asociada al ensamblado.Gets or sets the name of the culture associated with the assembly.

EscapedCodeBase EscapedCodeBase EscapedCodeBase EscapedCodeBase

Obtiene el identificador URI, incluidos los caracteres de escape, que representa el código base.Gets the URI, including escape characters, that represents the codebase.

Flags Flags Flags Flags

Obtiene o establece los atributos del ensamblado.Gets or sets the attributes of the assembly.

FullName FullName FullName FullName

Obtiene el nombre completo del ensamblado, que también se conoce como nombre para mostrar.Gets the full name of the assembly, also known as the display name.

HashAlgorithm HashAlgorithm HashAlgorithm HashAlgorithm

Indica o establece el algoritmo hash que utiliza el manifiesto del ensamblado.Gets or sets the hash algorithm used by the assembly manifest.

KeyPair KeyPair KeyPair KeyPair

Obtiene o establece el par de claves criptográficas pública y privada que se utiliza para crear una firma de nombre seguro para el ensamblado.Gets or sets the public and private cryptographic key pair that is used to create a strong name signature for the assembly.

Name Name Name Name

Obtiene o establece el nombre sencillo del ensamblado.Gets or sets the simple name of the assembly. Suele ser, aunque no necesariamente, el nombre del archivo de manifiesto del ensamblado, menos su extensión.This is usually, but not necessarily, the file name of the manifest file of the assembly, minus its extension.

ProcessorArchitecture ProcessorArchitecture ProcessorArchitecture ProcessorArchitecture

Obtiene o establece un valor que identifica el procesador y los bits por palabra de la plataforma de destino de una aplicación ejecutable.Gets or sets a value that identifies the processor and bits-per-word of the platform targeted by an executable.

Version Version Version Version

Obtiene o establece los números de versión principal, secundaria, de compilación y de revisión del ensamblado.Gets or sets the major, minor, build, and revision numbers of the assembly.

VersionCompatibility VersionCompatibility VersionCompatibility VersionCompatibility

Obtiene o establece la información relacionada con la compatibilidad del ensamblado con otros ensamblados.Gets or sets the information related to the assembly's compatibility with other assemblies.

Métodos

Clone() Clone() Clone() Clone()

Realiza una copia de este objeto AssemblyName.Makes a copy of this AssemblyName object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAssemblyName(String) GetAssemblyName(String) GetAssemblyName(String) GetAssemblyName(String)

Obtiene el nombre de ensamblado (AssemblyName) de un archivo dado.Gets the AssemblyName for a given file.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext) GetObjectData(SerializationInfo, StreamingContext)

Obtiene información de serialización con todos los datos necesarios para volver a crear una instancia de este AssemblyName.Gets serialization information with all the data needed to recreate an instance of this AssemblyName.

GetPublicKey() GetPublicKey() GetPublicKey() GetPublicKey()

Obtiene la clave pública del ensamblado.Gets the public key of the assembly.

GetPublicKeyToken() GetPublicKeyToken() GetPublicKeyToken() GetPublicKeyToken()

Obtiene el token de clave pública, formado por los 8 últimos bytes del hash SHA-1 de la clave pública con la que se firma la aplicación o el ensamblado.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.

GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object) OnDeserialization(Object)

Implementa la interfaz ISerializable. El evento de deserialización vuelve a llamar a este método cuando se completa la deserialización.Implements the ISerializable interface and is called back by the deserialization event when deserialization is complete.

ReferenceMatchesDefinition(AssemblyName, AssemblyName) ReferenceMatchesDefinition(AssemblyName, AssemblyName) ReferenceMatchesDefinition(AssemblyName, AssemblyName) ReferenceMatchesDefinition(AssemblyName, AssemblyName)

Devuelve un valor que indica si dos nombres de ensamblado son iguales.Returns a value indicating whether two assembly names are the same. La comparación se basa en los nombres de ensamblado simples.The comparison is based on the simple assembly names.

SetPublicKey(Byte[]) SetPublicKey(Byte[]) SetPublicKey(Byte[]) SetPublicKey(Byte[])

Establece la clave pública que identifica el ensamblado.Sets the public key identifying the assembly.

SetPublicKeyToken(Byte[]) SetPublicKeyToken(Byte[]) SetPublicKeyToken(Byte[]) SetPublicKeyToken(Byte[])

Establece el token de clave pública, formado por los últimos 8 bytes del código hash SHA-1 de la clave pública con la que se firma la aplicación o el ensamblado.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.

ToString() ToString() ToString() ToString()

Devuelve el nombre completo del ensamblado, también conocido como nombre para mostrar.Returns the full name of the assembly, also known as the display name.

Implementaciones de interfaz explícitas

_AssemblyName.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _AssemblyName.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _AssemblyName.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _AssemblyName.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

Asigna un conjunto de nombres a un conjunto correspondiente de identificadores de envío.Maps a set of names to a corresponding set of dispatch identifiers.

_AssemblyName.GetTypeInfo(UInt32, UInt32, IntPtr) _AssemblyName.GetTypeInfo(UInt32, UInt32, IntPtr) _AssemblyName.GetTypeInfo(UInt32, UInt32, IntPtr) _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.Retrieves the type information for an object, which can then be used to get the type information for an interface.

_AssemblyName.GetTypeInfoCount(UInt32) _AssemblyName.GetTypeInfoCount(UInt32) _AssemblyName.GetTypeInfoCount(UInt32) _AssemblyName.GetTypeInfoCount(UInt32)

Recupera el número de interfaces de información de tipo que proporciona un objeto (0 ó 1).Retrieves the number of type information interfaces that an object provides (either 0 or 1).

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

Proporciona acceso a las propiedades y los métodos expuestos por un objeto.Provides access to properties and methods exposed by an object.

Se aplica a

Consulte también: