Reference3.Identity-Eigenschaft

Ruft den eindeutigen Bezeichner des Verweises ab.

Namespace:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

Syntax

'Declaration
ReadOnly Property Identity As String
    Get
string Identity { get; }
property String^ Identity {
    String^ get ();
}
abstract Identity : string
function get Identity () : String

Eigenschaftswert

Typ: System.String
Die zurückgegebene Zeichenfolge hängt vom Verweistyp ab.

Verweistyp

Zurückgegebener Wert

Assembly

Assemblyname (Assemblyname ohne Pfad oder Erweiterung)

COM

Format:

"GUID\major.minor\localeid\wrappertool"

Beispiel:

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

wird für ActiveX Data Objects 2.5 zurückgegeben.

Systemeigen

Assemblyidentität der Assembly, auf die verwiesen wird.

Implementiert

Reference2.Identity

Hinweise

Alle Komponenten besitzen einen eindeutigen Bezeichner. Die Identity-Eigenschaft ruft diese Informationen ab. Diese Eigenschaft ist für jeden Verweis einmalig. Das liegt daran, dass eine Ausnahme ausgelöst wird, wenn Sie versuchen, einen Verweis hinzuzufügen, der dieselbe Identität wie ein bereits in der Auflistung vorhandener Verweis besitzt. Diese Eigenschaft ist dazu geeignet, die Reference3-Auflistung mithilfe der Item-Methode zu indizieren.

Beispiele

In diesem Beispiel werden einem geöffneten Visual Basic- oder Visual C#-Projekt eine Assembly und ein COM-Verweis hinzugefügt. Anschließend wird die jeweilige Identity-Eigenschaft angezeigt. Um dieses Beispiel als Add-In auszuführen, informieren Sie sich unter Gewusst wie: Kompilieren und Ausführen der Codebeispiele für das Automatisierungsobjektmodell.

Die Standardpfade für den hinzugefügten Verweis lauten: <Stammpfad der Installation>\Programme\Microsoft.NET\Primary Interop Assemblies für adodb.dll und <Stammpfad der Installation>\Programme\Gemeinsame Dateien\SpeechEngines\Microsoft für spcommon.dll. Ersetzen Sie <Dateipfad> im Beispiel durch diese oder andere geeignete Dateipfade.

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-Sicherheit

Siehe auch

Referenz

Reference3 Schnittstelle

Identity-Überladung

VSLangProj80-Namespace