Поделиться через


Reference3.SpecificVersion Property

Gets or sets whether only a specific version of the reference is used.

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

Syntax

'Declaration
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)

Property Value

Type: System.Boolean
A boolean value indicating whether only a certain version of the reference is used.

Remarks

This property allows you to target a specific version of a reference to an assembly for a project.

When used with a Reference item type, the Name property needs to be the full fusion name of the assembly to be resolved. The assembly is only resolved if fusion exactly matches the Name property.

When a project targets a .NET Framework version and references an assembly compiled for a higher .NET Framework version, the reference resolves only if it has SpecificVersion set to true.

When a project targets a profile and references an assembly that is not in the profile, the reference resolves only if it has SpecificVersion set to true.

Examples

This example displays the SpecificVersion value for each reference in an open Visual Basic or Visual C# project. To run this example as an add-in, see How to: Compile and Run the Automation Object Model Code Examples.

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 Security

See Also

Reference

Reference3 Interface

VSLangProj80 Namespace