AssemblyName AssemblyName AssemblyName AssemblyName Class

定义

完整描述程序集的唯一标识。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
继承
AssemblyNameAssemblyNameAssemblyNameAssemblyName
属性
实现

示例

此示例演示如何使用各种反射类来分析包含在程序集中的元数据。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()
'

注解

AssemblyName对象包含有关程序集的信息,您可以使用该程序集绑定到该程序集。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.

后面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、MyAssemblyContainingClass+NestedClass,MyAssembly

"+ +"\变成 "\++\\",而""\变成 ""。A "++" becomes "\+\+", and a "\" becomes "\\".

此限定名称可以保留,以后用于加载TypeThis qualified name can be persisted and later used to load the Type. 若要搜索并加载Type,请将与类型名称一起使用,或者使用GetType带有程序集限定类型名称的。To search for and load a Type, use GetType either with the type name only or with the assembly qualified type name. GetType只有类型名称才会Type在调用方的程序集中查找,然后在系统程序集中查找。GetType with the type name only will look for the Type in the caller's assembly and then in the System assembly. GetType具有程序集限定类型名称的将Type在任何程序集中查找。GetType with the assembly qualified type name will look for the Type in any assembly.

完全指定AssemblyName的必须具有名称、区域性、公钥或公钥令牌、主版本、次版本、内部版本号和修订号参数。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. 最后四个封装在Version类型中。The last four are packaged in the Version type.

若要创建一个简单名称,请AssemblyName使用无参数构造函数创建一个对象Name,并设置。To create a simple name, create an AssemblyName object using the parameterless constructor and set the Name. 其他属性是可选的。The other properties are optional.

若要创建完整的强名称,请AssemblyName使用无参数构造函数创建一个对象NameKeyPair并设置和。To create a full strong name, create an AssemblyName object using the parameterless constructor and set the Name and KeyPair. 其他属性是可选的。The other properties are optional. 使用SetPublicKeySetPublicKeyToken设置公钥和强名称。Use SetPublicKey and SetPublicKeyToken to set the public key and the strong name. 强名称签名总是使用SHA1哈希算法。The strong name signing always uses the SHA1 hash algorithm.

若要确保正确构造名称,请使用以下属性:To ensure that the names are constructed correctly, use the following properties:

还可以通过将/l选项与gacutil.exe (全局程序集缓存工具)一起使用来获取该名称。You can also get the name by using the /l option with the Gacutil.exe (Global Assembly Cache Tool)

对于部分指定的强名称,请使用AssemblyName无参数构造函数创建一个对象,并设置名称和公钥。For a partially specified strong name, create an AssemblyName object using the parameterless constructor and set the name and public key. 使用此类AssemblyName创建的程序集以后可以使用程序集链接器(al.exe)进行签名。An assembly created using such an AssemblyName can be signed later using the Assembly Linker (Al.exe).

可以指定KeyPair具有不一致值的公钥和。It is possible to specify a public key and a KeyPair with inconsistent values. 这对于开发人员方案非常有用。This can be useful in developer scenarios. 在这种情况下,使用GetPublicKey检索到的公钥指定了正确的公钥, KeyPair而指定了在开发过程中使用的公钥和私钥。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. 当运行时检测到KeyPair与公钥不匹配时,会在注册表中查找与公钥匹配的正确密钥。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.

显示名称AssemblyName的格式是以逗号分隔的以名称开头的 Unicode 字符串,如下所示: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程序集的文本名称。Name is the textual name of the assembly. CultureInfo是 RFC1766 格式定义的区域性。CultureInfo is the RFC1766-format-defined culture. MajorMinor、和Revision是程序集的主版本、次版本、内部版本号和修订号。 BuildMajor, Minor, Build, and Revision are the major version, minor version, build number, and revision number of the assembly. StrongName使用 SHA-1 哈希算法生成的公钥哈希值的十六进制编码低序位64位,以及由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. PublicKeyTokenSetPublicKey指定的十六进制编码的公钥。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.

如果已知道完整的公钥,则可能会将 PublicKey 替换为 Stackexchange.redis.strongname。If the full public key is known, then PublicKey may be substituted for StrongName.

另请注意,除Name(必须首先出现)外,参数的词法顺序并不重要。Also note that except for Name, which must come first, the lexical order of parameters is unimportant. 但是,未专门设置VersionCulture PublicKey StrongName 任何AssemblyName参数(、或)都被视为省略,然后将被视为 partial。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.

提供显示名称时,约定StrongName =nullPublicKey= null指示是否需要针对简单命名的程序集的绑定和匹配。When supplying a display name, the convention StrongName =null or PublicKey= null indicates that binding and matching against a simply named assembly is required. 此外,约定Culture= "" (表示空字符串的双引号)指示与默认区域性匹配。Additionally, the convention Culture= "" (double quote representing an empty string) indicates matching against the default culture.

下面的示例演示AssemblyName了一个具有默认区域性的简单命名的程序集。The following example shows an AssemblyName for a simply named assembly with default culture.

ExampleAssembly, Culture=""  

下面的示例演示区域性为“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  

构造函数

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

初始化 AssemblyName 类的新实例。Initializes a new instance of the AssemblyName class.

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

使用指定的显示名称初始化 AssemblyName 类的新实例。Initializes a new instance of the AssemblyName class with the specified display name.

属性

CodeBase CodeBase CodeBase CodeBase

获取或设置程序集的 URL 位置。Gets or sets the location of the assembly as a URL.

ContentType ContentType ContentType ContentType

获取或设置指示程序集包含的内容类型的值。Gets or sets a value that indicates what type of content the assembly contains.

CultureInfo CultureInfo CultureInfo CultureInfo

获取或设置程序集支持的区域性。Gets or sets the culture supported by the assembly.

CultureName CultureName CultureName CultureName

获取或设置与此程序集关联的区域性名称。Gets or sets the name of the culture associated with the assembly.

EscapedCodeBase EscapedCodeBase EscapedCodeBase EscapedCodeBase

获取 URI,包括表示基本代码的转义符。Gets the URI, including escape characters, that represents the codebase.

Flags Flags Flags Flags

获取或设置该程序集的属性。Gets or sets the attributes of the assembly.

FullName FullName FullName FullName

获取程序集的全名(也称为显示名称)。Gets the full name of the assembly, also known as the display name.

HashAlgorithm HashAlgorithm HashAlgorithm HashAlgorithm

获取或设置程序集清单使用的哈希算法。Gets or sets the hash algorithm used by the assembly manifest.

KeyPair KeyPair KeyPair KeyPair

获取或设置用于为程序集创建强名称签名的加密公钥/私钥对。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

获取或设置程序集的简单名称。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.

ProcessorArchitecture ProcessorArchitecture ProcessorArchitecture ProcessorArchitecture

获取或设置一个值,该值标识可执行文件的目标平台的处理器和每字位数。Gets or sets a value that identifies the processor and bits-per-word of the platform targeted by an executable.

Version Version Version Version

获取或设置程序集的主版本号、次版本号、内部版本号和修订号。Gets or sets the major, minor, build, and revision numbers of the assembly.

VersionCompatibility VersionCompatibility VersionCompatibility VersionCompatibility

获取或设置与程序集同其他程序集的兼容性相关的信息。Gets or sets the information related to the assembly's compatibility with other assemblies.

方法

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

制作此 AssemblyName 对象的副本。Makes a copy of this AssemblyName object.

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

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

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

获取给定文件的 AssemblyNameGets the AssemblyName for a given file.

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

作为默认哈希函数。Serves as the default hash function.

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

获取序列化信息,其中包含重新创建此 AssemblyName 实例所需的所有数据。Gets serialization information with all the data needed to recreate an instance of this AssemblyName.

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

获取程序集的公钥。Gets the public key of the assembly.

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

获取公钥标记,该标记为应用程序或程序集签名时所用公钥的 SHA-1 哈希值的最后 8 个字节。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()

获取当前实例的 TypeGets the Type of the current instance.

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

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

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

实现 ISerializable 接口,并在完成反序列化后由反序列化事件回调。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)

返回指示两个程序集名称是否相同的值。Returns a value indicating whether two assembly names are the same. 该比较基于简单的程序集名称。The comparison is based on the simple assembly names.

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

设置用于标识程序集的公钥。Sets the public key identifying the assembly.

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

设置公钥标记,该标记为应用程序或程序集签名时所用公钥的 SHA-1 哈希值的最后 8 个字节。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()

返回程序集的全名,即所谓的显示名称。Returns the full name of the assembly, also known as the display name.

显式界面实现

_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)

将一组名称映射为对应的一组调度标识符。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)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。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)

检索对象提供的类型信息接口的数量(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)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

适用于

另请参阅