Reference3.Identity 속성

참조의 고유 식별자를 가져옵니다.

네임스페이스:  VSLangProj80
어셈블리:  VSLangProj80(VSLangProj80.dll)

구문

‘선언
ReadOnly Property Identity As String
string Identity { get; }
property String^ Identity {
    String^ get ();
}
abstract Identity : string
function get Identity () : String

속성 값

형식: System.String
반환되는 문자열은 참조 형식에 따라 다릅니다.

참조 형식

반환 값

Assembly

어셈블리 이름(경로나 확장명이 없는 어셈블리 이름)

COM

형식은 다음과 같습니다.

"GUID\major.minor\localeid\wrappertool"

다음 예제를 참조하십시오.

"{00000205-0000-0010-8000-00AA006D2EA4}\2.5\409\tlbimp"

ActiveX Data Objects 2.5의 반환 값입니다.

Native

참조되고 있는 어셈블리의 어셈블리 ID

설명

모든 구성 요소에는 고유 ID가 있으며Identity 속성을 통해 이 정보를 가져옵니다.이 속성은 각 참조에 대해 고유하며 컬렉션에 이미 있는 참조와 동일한 ID를 가진 참조를 추가하려고 하면 예외가 발생합니다.이 속성은 Item 메서드를 사용하여 Reference3 컬렉션을 인덱싱하는 데 적합합니다.

예제

이 예제에서는 열린 Visual Basic 또는 Visual C# 프로젝트에 어셈블리 및 COM 참조를 추가하고 각 참조의 Identity 속성을 표시합니다.이 예제를 추가 기능으로 실행하려면 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

추가되는 참조의 기본 경로는 adodb.dll의 경우 <설치 루트>\Program Files\Microsoft.NET\Primary Interop Assemblies이고 spcommon.dll의 경우 <설치 루트>\Program Files\Common Files\SpeechEngines\Microsoft입니다.예제의 <file path>를 이 경로 또는 적절한 다른 파일 경로로 바꿉니다.

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object,_
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    ShowIdentity (applicationObject)
End Sub
Sub ShowIdentity(ByVal dte As DTE2)
    Dim aProject As Project
    Dim aVSProject As VSProject2
    aProject = applicationObject.Solution.Projects.Item(1)
    aVSProject = _
CType(applicationObject.Solution.Projects.Item(1).Object, VSProject2)
    ' Add an Assembly reference and display its identity.
    Dim newRef As Reference3
    ' Replace the <file path> with an actual file path.
    newRef = aVSProject.References.Add("<file path>\adodb.dll")
    MsgBox("Added an Assembly reference, named: " & newRef.Name)
    MsgBox("The Identity of " & newRef.Name & " is " & newRef.Identity)
    ' Add a COM reference and display its identity.
    ' Replace the <file path> with an actual file path.
    newRef = aVSProject.References.Add("<file path>\spcommon.dll")
    MsgBox("Added a COM reference, named: " & newRef.Name)
    MsgBox("The Identity of " & newRef.Name & " is " & newRef.Identity)
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    ShowIdentity(((DTE2)applicationObject));
}
public void ShowIdentity(DTE2 dte)
{
    // The first project is a Visual Basic or C# project.
    VSProject2 vsProject = 
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    Reference3 aRef = null;
    // Add an Assembly reference and display its identity.
    // Replace <file path> with an actual file path.
    aRef = (Reference3)vsProject.References.Add
(@"<file path>\adodb.dll");
    MessageBox.Show("Added an Assembly reference, named: " 
+ aRef.Name);
    MessageBox.Show("The Identity of " + aRef.Name + " is " 
+ aRef.Identity);
    // Add a COM reference and display its identity.
    // Replace <file path> with an actual file path.
    aRef = (Reference3)vsProject.References.Add
(@"<file path>\spcommon.dll");
    MessageBox.Show("Added a COM reference, named: " 
+ aRef.Name);
    MessageBox.Show("The Identity of " + aRef.Name + " is " 
+ aRef.Identity);
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

Reference3 인터페이스

Identity 오버로드

VSLangProj80 네임스페이스