Reference3.Version 屬性
取得指定參考的版本。
命名空間: VSLangProj80
組件: VSLangProj80 (在 VSLangProj80.dll 中)
語法
'宣告
ReadOnly Property Version As String
string Version { get; }
property String^ Version {
String^ get ();
}
abstract Version : string
function get Version () : String
屬性值
型別:System.String
字串,表示版本號碼。
備註
版本號碼的格式如下:
主要版本 + 次要版本 + 組建版本 + 修訂。
例如 10.3.5400.3。
範例
此範例會在開啟的 Visual Basic 或 Visual C# 專案中逐一查看參考,並且顯示其版本號碼。若要將此範例當做增益集來執行,請參閱 HOW TO:編譯和執行 Automation 物件模型程式碼範例。
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)
DisplayVersion(applicationObject)
End Sub
Public Sub DisplayVersion(ByVal dte As DTE2)
' The first project is a Visual Basic or C# project.
Dim vsProject As VSProject2 = _
CType(applicationObject.Solution.Projects.Item(1).Object, _
VSProject2)
Dim aRef As Reference3
Dim refStr As String
refStr = ""
For Each aRef In VSProject.References
refStr += (aRef.Name & " has a version number: " _
& aRef.Version & vbCr & vbCr)
Next
MsgBox(refStr)
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;
DisplayVersion(((DTE2)applicationObject));
}
public void DisplayVersion(DTE2 dte)
{
// The first project is a Visual Basic or C# project.
VSProject2 aProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
Reference3 aRef = null;
string refStr = null;
refStr = "";
foreach (VSLangProj80.Reference3 temp in aProject.References)
{
aRef = temp;
refStr += (aRef.Name + " has a version number: " +aRef.Version
+ "\n" + "\n");
}
MessageBox.Show(refStr);
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。