다음을 통해 공유


AssemblyName 클래스

어셈블리의 고유 ID에 대해 자세히 설명합니다.

네임스페이스: System.Reflection
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<SerializableAttribute> _
<ClassInterfaceAttribute(ClassInterfaceType.None)> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class AssemblyName
    Implements _AssemblyName, ICloneable, ISerializable, IDeserializationCallback
‘사용 방법
Dim instance As AssemblyName
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType.None)] 
[ComVisibleAttribute(true)] 
public sealed class AssemblyName : _AssemblyName, ICloneable, ISerializable, 
    IDeserializationCallback
[SerializableAttribute] 
[ClassInterfaceAttribute(ClassInterfaceType::None)] 
[ComVisibleAttribute(true)] 
public ref class AssemblyName sealed : _AssemblyName, ICloneable, ISerializable, 
    IDeserializationCallback
/** @attribute SerializableAttribute() */ 
/** @attribute ClassInterfaceAttribute(ClassInterfaceType.None) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class AssemblyName implements _AssemblyName, ICloneable, 
    ISerializable, IDeserializationCallback
SerializableAttribute 
ClassInterfaceAttribute(ClassInterfaceType.None) 
ComVisibleAttribute(true) 
public final class AssemblyName implements _AssemblyName, ICloneable, 
    ISerializable, IDeserializationCallback

설명

AssemblyName 개체에는 어셈블리에 대한 정보가 포함되어 있으며, 이 정보는 해당 어셈블리에 바인딩하는 데 사용할 수 있습니다. 어셈블리 ID는 다음과 같은 요소로 구성됩니다.

  • 단순한 이름

  • 버전 번호

  • 암호화 키 쌍

  • 지원되는 culture

일반적으로 단순한 이름은 확장명이 제외된 매니페스트 파일 이름입니다. 키 쌍에는 어셈블리의 강력한 이름 시그니처를 만드는 데 사용되는 공개 키와 개인 키가 포함됩니다.

공용 언어 런타임을 지원하는 모든 컴파일러에서는 중첩 클래스의 단순한 이름을 내보내고, 리플렉션에서는 쿼리 시 다음 규칙에 따라 변환된 이름을 생성합니다.

구분 기호

의미

백슬래시(\)

이스케이프 문자입니다.

쉼표(,)

어셈블리 이름 앞에 붙습니다.

더하기 기호(+)

중첩 클래스 앞에 붙습니다.

예를 들면, 다음과 같은 이름이 클래스의 정규화된 이름이 될 수 있습니다.

ContainingClass+NestedClass,MyAssembly

"++"는 "\+\+"가 되고 "\"는 "\\"가 됩니다.

이 정규화된 이름은 그대로 유지되었다가 나중에 Type을 로드하는 데 사용될 수 있습니다. Type을 검색 및 로드하려면 형식 이름만 포함되거나 어셈블리 한정 형식 이름이 있는 GetType을 사용합니다. 형식 이름만 있는 GetType에서는 호출자의 어셈블리와 System 어셈블리의 Type을 찾고, 어셈블리 한정 형식 이름이 있는 GetType에서는 모든 어셈블리의 Type을 찾습니다.

완전하게 지정된 AssemblyName에는 이름, culture, 공개 키나 공개 키 토큰, 주 버전, 부 버전, 빌드 번호 및 수정 번호 매개 변수가 포함되어야 합니다. 마지막 네 가지 항목은 Version 형식으로 구성됩니다.

단순한 이름을 만들려면 기본 생성자를 사용하여 AssemblyName 개체를 만든 다음 Name을 설정합니다. 나머지 속성은 선택적 요소입니다.

강력한 전체 이름을 만들려면 기본 생성자를 사용하여 AssemblyName 개체를 만든 다음 NameKeyPair를 설정합니다. 나머지 속성은 선택적 요소입니다. SetPublicKeySetPublicKeyToken을 사용하여 공개 키 및 강력한 이름을 설정합니다. 강력한 이름으로 서명하는 경우에는 항상 SHA1 해시 알고리즘을 사용합니다.

이름을 제대로 생성하려면 다음과 같은 속성을 사용합니다.

전역 어셈블리 캐시 도구(Gacutil.exe)/l 옵션을 사용하여 이름을 가져올 수도 있습니다.

부분적으로 지정된 강력한 이름의 경우 기본 생성자를 사용하여 AssemblyName 개체를 만든 다음 이름과 공개 키를 설정합니다. AssemblyName 등을 사용하여 만든 어셈블리는 나중에 어셈블리 링커(Al.exe)를 사용하여 서명할 수 있습니다.

공개 키와 KeyPair를 일치하지 않는 값으로 지정할 수 있습니다. 이렇게 하면 개발자 시나리오에서 유용하게 사용됩니다 이 경우에 GetPublicKey를 사용하여 검색한 공개 키는 올바른 공개 키를 지정하는 반면 KeyPair는 개발 과정에 사용되는 공개 및 개인 키를 지정합니다. 런타임에서 KeyPair와 공개 키가 일치하지 않음을 감지하면 공개 키와 일치하는 올바른 키를 레지스트리에서 찾습니다.

AssemblyName의 표시 이름 형식은 다음과 같이 이름으로 시작하는 쉼표로 구분된 유니코드 문자열입니다.

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

Name은 어셈블리의 텍스트 이름입니다. CultureInfo는 RFC1766 형식으로 정의된 culture입니다. Major, Minor, BuildRevision은 어셈블리의 주 버전, 부 버전, 빌드 번호 및 수정 번호입니다. StrongName은 SHA-1 해시 알고리즘을 사용하여 생성된 공개 키와 SetPublicKey로 지정된 공개 키의 해시 값이 16진수로 인코딩된 하위 64비트입니다. PublicKeyTokenSetPublicKey로 지정된 16진수로 인코딩된 공개 키입니다.

16진수로 인코딩하는 작업은 이진 개체의 각 바이트를 최하위 바이트부터 최상위 바이트까지 두 개의 16진 문자로 변환하는 것입니다. 다른 표시 값은 필요에 따라 추가됩니다.

전체 공개 키를 알면 PublicKey를 StrongName 대신 사용할 수 있습니다.

또한 처음에 와야 하는 Name을 제외하고 매개 변수의 어휘 순서는 중요하지 않습니다. 그러나 구체적으로 설정되지 않은 모든 매개 변수(Version, Culture, StrongName 또는 PublicKey)는 생략된 것으로 간주되고, 그에 따라 AssemblyName은 부분 이름으로 간주됩니다. 부분 정보를 지정할 때 Name 매개 변수는 위에서 설명된 순서로 지정해야 합니다.

표시 이름을 제공할 때 StrongName =null 또는 PublicKey= null 규칙은 단순한 이름의 어셈블리에 대해 바인딩 및 일치가 수행되어야 함을 나타냅니다. 또한 Culture= ""(큰따옴표는 빈 문자열을 나타냄) 규칙은 기본 culture에 대해 일치가 수행됨을 나타냅니다.

다음 코드 예제에서는 기본 culture를 사용하는 단순한 이름의 어셈블리의 AssemblyName을 보여 줍니다.

com.microsoft.crypto,
    Culture=""

다음 코드 예제에서는 culture "en"을 사용하는 강력한 이름의 어셈블리에 대해 완전하게 지정된 참조를 보여 줍니다.

com.microsoft.crypto, Culture=en, PublicKeyToken=a5d015c7d5a0b012, Version=1.0.0.0

예제

이 예제에서는 다양한 리플렉션 클래스를 사용하여 어셈블리에 포함된 메타데이터를 분석하는 방법을 보여 줍니다.

Imports System
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] = System.Reflection.Assembly.GetExecutingAssembly()
        Display(indent, "Assembly identity={0}", a.FullName)
        Display(indent + 1, "Codebase={0}", a.CodeBase)

        ' Display the set of assemblies our assemblies references.
        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()
'

상속 계층 구조

System.Object
  System.Reflection.AssemblyName

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

AssemblyName 멤버
System.Reflection 네임스페이스
Version
GetPublicKey
GetPublicKeyToken
SetPublicKey
SetPublicKeyToken
FullName
GetType
AssemblyQualifiedName

기타 리소스

정규화된 형식 이름 지정