Condividi tramite


Proprietà Reference3.MajorVersion

Ottiene il numero di versione principale del riferimento.

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

Sintassi

'Dichiarazione
ReadOnly Property MajorVersion As Integer
int MajorVersion { get; }
property int MajorVersion {
    int get ();
}
abstract MajorVersion : int
function get MajorVersion () : int

Valore proprietà

Tipo: System.Int32
Un Integer del cui valore dipende dal tipo di riferimento.

Tipo di riferimento

valore restituito

Assembly

Numero di importante rilascio di riferimento; 0-9999.

COM

Un valore di tipo Int.

Note

la versione di un riferimento in modo univoco è identificata da quattro componenti: i principali, secondario, compilazionee revisione.i principali e secondario i componenti sono necessarie.revisione il componente è facoltativa quando compilazione non è definito.Gli oggetti COM hanno revisione e compilazione componenti.Per ulteriori informazioni, vedere Controllo delle versioni degli assembly.

Esempi

In questo esempio viene aggiunto un assembly e un riferimento COM a un elemento aperto Visual Basic o Visual C# il progetto e visualizza i rispettivi numeri di versione principale eseguire questo esempio viene illustrato come componente aggiuntivo, vedere Procedura: compilare ed eseguire gli esempi di codice del modello a oggetti di automazione.

I percorsi predefiniti per il riferimento aggiunti sono: <radice dell'installazione> \Program Files\Microsoft.NET\Primary Interop Assemblies per adodb.dll e <radice dell'installazione> \Program Files\Common Files\SpeechEngines\Microsoft per spcommon.dll.di sostituzione <percorso del file> nell'esempio con questi o altri percorsi dei file 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)
    GetMajorVersion(applicationObject)
End Sub
Sub GetMajorVersion(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 major version.
    ' Replace <file path> with an actual file path.
    Dim newRef As Reference3
    newRef = _
    CType(aVSProject.References.Add("<file path>\adodb.dll"), _
    Reference3)
    MsgBox("Added an Assembly reference, named: " & newRef.Name)
    MsgBox("The Major version of " & newRef.Name & " is " _
    & newRef.MajorVersion.ToString())
    ' Add a COM reference and display its major version.
    ' 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 major version of " & newRef.Name & " is " _
    & newRef.MajorVersion.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;
    GetMajorVersion(((DTE2)applicationObject));
}
public void GetMajorVersion(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 major version.
    // 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 major version of " + aRef.Name + " is " 
+ aRef.MajorVersion.ToString());
    // Add a COM reference and display its major version.
    // 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 major version of " + aRef.Name + " is " 
+ aRef.MajorVersion.ToString());
}

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Reference3 Interfaccia

Overload MajorVersion

Spazio dei nomi VSLangProj80