共用方式為


Reference3.SpecificVersion 屬性

取得或設定是否僅使用特定版本的參考。

命名空間:  VSLangProj80
組件:  VSLangProj80 (在 VSLangProj80.dll 中)

語法

'宣告
Property SpecificVersion As Boolean
bool SpecificVersion { get; set; }
property bool SpecificVersion {
    bool get ();
    void set (bool value);
}
abstract SpecificVersion : bool with get, set
function get SpecificVersion () : boolean
function set SpecificVersion (value : boolean)

屬性值

型別:System.Boolean
boolean 值,指出是否僅使用特定版本的參考。

備註

此屬性可讓您將特定版本的參考當做專案組件的目標。

與參照項目型別搭合使用時,Name 屬性必須是待解析組件的完整融合名稱。如果融合完全符合 Name 屬性,才會解析組件。

當專案以.NET Framework 版本為目標,並且參照較新版 .NET Framework 所編譯的組件時,參照只會在 SpecificVersion 設為 True 時才會解析。

當專案以設定檔為目標,並參照設定檔中沒有的組件時,則參照只有在 SpecificVersion 設為 True 時才會解析。

範例

此範例會針對開啟的 Visual Basic 或 Visual C# 專案中的每個參考,顯示 SpecificVersion 值。若要將此範例當做增益集來執行,請參閱 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)
    DisplaySpecificVersionValue(applicationObject)
End Sub
Public Sub DisplaySpecificVersionValue(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 specific version value of: " _
        & aRef.SpecificVersion.ToString() & 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;
    DisplaySpecificVersionValue(((DTE2)applicationObject));
}
public void DisplaySpecificVersionValue(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 specific version value of: " 
+aRef.SpecificVersion.ToString() + "\n" + "\n");
    }
    MessageBox.Show(refStr);
}

.NET Framework 安全性

請參閱

參考

Reference3 介面

VSLangProj80 命名空間