Share via


Reference3.StrongName, propriété

Obtient une valeur indiquant si la référence est signée à l'aide d'une paire de clés publique/privée.

Espace de noms :  VSLangProj80
Assembly :  VSLangProj80 (dans VSLangProj80.dll)

Syntaxe

'Déclaration
ReadOnly Property StrongName As Boolean
    Get
bool StrongName { get; }
property bool StrongName {
    bool get ();
}
abstract StrongName : bool
function get StrongName () : boolean

Valeur de propriété

Type : System.Boolean
Une valeur boolean qui indique si la référence est signée à l'aide d'une paire de clés publiques/privées.

Implémentations

Reference2.StrongName

Notes

La valeur retournée dépend du type référence.

Type référence

Valeur de retour

Assembly

True si la référence a un nom fort.

COM

False ; les objets COM n'ont pas de noms forts.

Seuls les assemblys dotés de noms forts peuvent être placés dans le Global Assembly Cache. Pour plus d'informations sur les noms forts et le Global Assembly Cache, consultez Assemblys avec nom fort, Global Assembly Cache et Utilisation d'assemblys et du Global Assembly Cache.

Exemples

Cet exemple ajoute un assembly et une référence COM à un projet Visual Basic ou Visual C# ouvert. Il détermine ensuite si la référence d'assembly a un nom fort. Pour la référence COM, StrongName est false. Pour exécuter cet exemple comme un complément, consultez Comment : compiler et exécuter les exemples de code du modèle objet Automation.

Les chemins d'accès par défaut pour les références ajoutées sont : <racine d'installation>\Program Files\Microsoft.NET\Primary Interop Assemblies pour adodb.dll et <racine d'installation>\Program Files\Common Files\SpeechEngines\Microsoft pour spcommon.dll. Dans l'exemple, remplacez <chemin d'accès au fichier> par ceux-ci ou par d'autres chemins appropriés.

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());
}

Sécurité .NET Framework

Voir aussi

Référence

Reference3 Interface

StrongName, surcharge

VSLangProj80, espace de noms