Reference3.BuildNumber 屬性
取得參考的組建編號。
命名空間: VSLangProj80
組件: VSLangProj80 (在 VSLangProj80.dll 中)
語法
'宣告
ReadOnly Property BuildNumber As Integer
Get
int BuildNumber { get; }
property int BuildNumber {
int get ();
}
abstract BuildNumber : int
function get BuildNumber () : int
屬性值
型別:System.Int32
長整數值。視參考型別而定傳回不同值。
參考型別 |
傳回值 |
---|---|
組件 |
參考的組建編號:0-9999。 |
COM |
0 |
實作
備註
BuildNumber 屬性取得版本編號的 build 元件。 參考的版本可以經由四個元件進行唯一識別:major、minor、build 和 revision。 major 和 minor 元件都是必要項。 沒有定義 build 時,revision 元件是選擇項。 COM 物件沒有 revision 和 build 元件。 如需詳細資訊,請參閱組件版本控制。
範例
此範例會將組件和 COM 參考加入至開啟的 Visual Basic 或 Visual C# 專案,並且在訊息方塊中顯示每個參考的組建編號。 若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。
新增的參考之預設路徑:adodb.dll 為 <installation root>\Program Files\Microsoft.NET\Primary Interop Assemblies,以及 spcommon.dll 為 <installation root>\Program Files\Common Files\SpeechEngines\Microsoft。 以這兩個或其他適當的檔案路徑取代範例中的 <file path>。
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。