Compartir a través de


Reference3.MajorVersion (Propiedad)

Obtiene el número de versión principal de la referencia.

Espacio de nombres:  VSLangProj80
Ensamblado:  VSLangProj80 (en VSLangProj80.dll)

Sintaxis

'Declaración
ReadOnly Property MajorVersion As Integer
    Get
int MajorVersion { get; }
property int MajorVersion {
    int get ();
}
abstract MajorVersion : int
function get MajorVersion () : int

Valor de propiedad

Tipo: System.Int32
Entero cuyo valor depende del tipo de referencia.

Tipo de referencia

Valor devuelto

Ensamblado

Número de versión principal de la referencia; 0-9999.

COM

Valor Int.

Implementaciones

Reference2.MajorVersion

Comentarios

La versión de una referencia se identifica de forma única mediante cuatro componentes: major, minor, build y revision. Los componentes major y minor son obligatorios. El componente revision será opcional cuando no se haya definido build. Los objetos COM no tienen los componentes revision y build. Para obtener más información, vea Versiones de los ensamblados.

Ejemplos

En este ejemplo se agregan un ensamblado y una referencia COM a un proyecto de Visual Basic o Visual C# abierto y se muestran sus números de versión principal. Para ejecutar este ejemplo como complemento, vea Cómo: Compilar y ejecutar los ejemplos de código del modelo de objetos de automatización.

Las rutas de acceso predeterminadas para la referencia agregada son: <raíz de instalación>\Archivos de programa\Microsoft.NET\Primary Interop Assemblies for adodb.dll y <raíz de instalación>\Archivos de programa\Common Files\SpeechEngines\Microsoft for spcommon.dll. En el ejemplo, reemplace <file path> por éstas u otras rutas de acceso a archivos apropiadas.

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

Seguridad de .NET Framework

Vea también

Referencia

Reference3 Interfaz

MajorVersion (Sobrecarga)

VSLangProj80 (Espacio de nombres)