Freigeben über


Reference3.StrongName-Eigenschaft

Stellt fest, ob der Verweis mit einem Schlüsselpaar aus einem öffentlichen und einem privaten Schlüssel signiert ist.

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

Syntax

'Declaration
ReadOnly Property StrongName As Boolean
bool StrongName { get; }
property bool StrongName {
    bool get ();
}
abstract StrongName : bool with get
function get StrongName () : boolean

Eigenschaftswert

Typ: Boolean
Ein boolean-Wert, der angibt, ob der Verweis mit einem Schlüsselpaar aus einem öffentlichen und einem privaten Schlüssel signiert ist.

Hinweise

Der zurückgegebene Wert richtet sich nach dem Verweistyp.

Verweistyp

Zurückgegebener Wert

Assembly

True, wenn der Verweis einen starken Namen besitzt.

COM

False; COM-Objekte haben keine starken Namen.

Nur Assemblys mit starken Namen können in den globalen Assemblycache gestellt werden. Weitere Informationen zu starken Namen und dem globalen Assemblycache finden Sie unter Assemblys mit starkem Namen, Globaler Assemblycache und Arbeiten mit Assemblys und dem globalen Assemblychache.

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 bestimmt, ob der Assemblyverweis über einen starken Namen verfügt. In Bezug auf den COM-Verweis hat StrongName den Wert false. 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)
    DisplayStrongNameValue(applicationObject)
End Sub
Sub DisplayStrongNameValue(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 strong name value.
    Dim newRef As Reference3
    ' Replace the <file path> with an actual file path.
    newRef = CType(aVSProject.References.Add("<file path>\adodb.dll"), _
    Reference3)
    MsgBox("Added an assembly reference, named: " & newRef.Name)
    MsgBox("The StrongName value of " & newRef.Name & " is " _
    & newRef.StrongName.ToString())
    ' Add a COM reference and display its strong name value.
    ' Replace <file path> with an actual file path.
    newRef = CType(aVSProject.References.Add
("<file path>\spcommon.dll"), Reference3)
    MsgBox("Added a COM reference, named: " & newRef.Name)
    MsgBox("The StrongName value of " & newRef.Name & " is " _
    & newRef.StrongName.ToString())
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;
    DisplayStrongNameValue(((DTE2)applicationObject));
}
public void DisplayStrongNameValue(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 strong name value.
    ' Replace the <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 StrongName value of " + aRef.Name + " is "
+ aRef.StrongName.ToString());
    // Add a COM reference and display its strong name value.
    ' 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 StrongName value of " + aRef.Name + " is "
+ aRef.StrongName.ToString());
}

.NET Framework-Sicherheit

Siehe auch

Referenz

Reference3 Schnittstelle

VSLangProj80-Namespace