Condividi tramite


Proprietà Reference3.StrongName

Ottiene l'indicazione che stabilisce se il riferimento è firmato con una coppia di chiavi pubblica/privata.

Spazio dei nomi:  VSLangProj80
Assembly:  VSLangProj80 (in VSLangProj80.dll)

Sintassi

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

Valore proprietà

Tipo: Boolean
Valore boolean che indica se il riferimento è firmato con una coppia di chiavi pubblica/privata.

Note

Il valore restituito dipende dal tipo di riferimento.

Tipo di riferimento

Valore restituito

Assembly

True se il riferimento dispone di un nome sicuro.

COM

False; gli oggetti COM non dispongono di nome sicuro.

Soltanto gli assembly dotati di nome sicuro possono essere posti nella Global Assembly Cache. Per ulteriori informazioni sui nomi sicuri e sulla Global Assembly Cache, vedere Assembly con nomi sicuri, Global Assembly Cache e Utilizzo di assembly e della Global Assembly Cache.

Esempi

Nell'esempio riportato di seguito vengono aggiunti un assembly e un riferimento COM a un progetto aperto di Visual Basic o Visual C#. Viene quindi stabilito se al riferimento dell'assembly è stato assegnato un nome sicuro. Per il riferimento COM, StrongName è false. Per eseguire questo esempio come componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

I percorsi predefiniti per il riferimento aggiunto sono: <directory radice di installazione>\Programmi\Microsoft.NET\Primary Interop Assemblies per adodb.dll e <directory radice di installazione>\Programmi\File comuni\SpeechEngines\Microsoft per spcommon.dll. Sostituire <percorso file> dell'esempio con questi percorsi di file o altri percorsi appropriati.

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Reference3 Interfaccia

Spazio dei nomi VSLangProj80