Dela via


Reference3.BuildNumber Property

Gets the build number of the reference.

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

Syntax

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

Property Value

Type: System.Int32
A Long value. The value returned depends on the reference type.

Reference Type

Value Returned

Assembly

Build number of the reference; 0-9999.

COM

0

Implements

Reference2.BuildNumber

Remarks

The BuildNumber property gets the build component of a version number. The version of a reference is uniquely identified by four components: major, minor, build, and revision. The major and minor components are required. The revision component is optional when build is not defined. COM objects do not have revision and build components. For more information, see Assembly Versioning.

Examples

This example adds an assembly and a COM reference to an open Visual Basic or Visual C# project and displays the build number for each reference in a message box. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

The default paths for the added references are: <installation root>\Program Files\Microsoft.NET\Primary Interop Assemblies for adodb.dll, and <installation root>\Program Files\Common Files\SpeechEngines\Microsoft for spcommon.dll. Replace <file path> in the example with these or other appropriate file paths.

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)
    AddRefPlusBuild(applicationObject)
End Sub
Sub AddRefPlusBuild(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 build number.
    Dim newRef As Reference3
    ' Replace <file path> with an actual file path.
    newRef = aVSProject.References.Add("<file path>\adodb.dll")
    MsgBox("The " & newRef.Name() & " has a build number:" & vbCr _
    & newRef.BuildNumber.ToString())
    ' Add a COM reference and display its build number. Should be 0.
    ' Replace <file path> with an actual file path.
    newRef = aVSProject.References.Add("<file path>\spcommon.dll")
    MsgBox("The " & newRef.Name() & " has a build number:" & _
    vbCr & newRef.BuildNumber.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;
    AddRefPlusBuild(((DTE2)applicationObject));
}
public void AddRefPlusBuild(DTE2 dte)
{
    Project aProject = null;
    VSProject2 aVSProject = null;
    aProject = applicationObject.Solution.Projects.Item(1);
    aVSProject = 
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    // Add an Asembly reference and display its build number.
    Reference3 newRef = null;
    // Replace <file path> with an actual file path.
    newRef = ((Reference3)(aVSProject.References.Add(@"
<file path>\adodb.dll")));
    MessageBox.Show("The " + newRef.Name.ToString() + 
" has a build number:" + "\n" + newRef.BuildNumber.ToString());  
    // Add a COM reference and display its build number.
    // Replace <file path> with an actual file path.
    newRef = ((Reference3)(aVSProject.References.Add(@"
<file path>\spcommon.dll")));
    MessageBox.Show("The " + newRef.Name.ToString() + " has a build 
number:" + "\n" + newRef.BuildNumber.ToString()); 
}

.NET Framework Security

See Also

Reference

Reference3 Interface

VSLangProj80 Namespace