Reference3.RuntimeVersion 属性

定义

获取针对其生成引用的运行时的版本。 这仅适用于 .NET 引用。

public:
 property System::String ^ RuntimeVersion { System::String ^ get(); };
public:
 property Platform::String ^ RuntimeVersion { Platform::String ^ get(); };
[System.Runtime.InteropServices.DispId(100)]
public string RuntimeVersion { [System.Runtime.InteropServices.DispId(100)] get; }
[<System.Runtime.InteropServices.DispId(100)>]
[<get: System.Runtime.InteropServices.DispId(100)>]
member this.RuntimeVersion : string
Public ReadOnly Property RuntimeVersion As String

属性值

String

一个字符串,表示生成 .NET 引用所针对的运行时版本。

实现

属性

示例

此示例显示打开或项目的第一个引用的运行时 Visual Basic 版本 Visual C# 。 若要将此示例作为外接程序运行,请参阅 如何:编译和运行自动化对象模型代码示例

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)  
    GetRuntimeVersion(applicationObject)  
End Sub  
Sub GetRuntimeVersion(ByVal dte As DTE2)  
    Dim aProject As Project  
    Dim aVSProject As VSProject2  
    ' The first project is a Visual Basic or C# project.  
    aProject = applicationObject.Solution.Projects.Item(1)  
    aVSProject =_  
    CType(applicationObject.Solution.Projects.Item(1).Object _  
    , VSProject2)  
    Dim newRef As Reference3  
    newRef = CType(aVSProject.References.Item(1), Reference3)  
    MsgBox("The name of the first reference in the project is: " _  
    & newRef.Name & vbCr & "its runtime version is: " _  
    & newRef.RuntimeVersion)  
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;  
    GetRuntimeVersion(((DTE2)applicationObject));  
}  
public void GetRuntimeVersion(DTE2 dte)  
{  
    // The first project is a Visual Basic or C# project.  
    VSProject2 aVSProject =  
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));  
    Reference3 aRef = null;  
    aRef = ((Reference3)(aVSProject.References.Item(1)));  
    MessageBox.Show("The first reference in the project is: "  
+ aRef.Name + "\n" + "and its runtime version is: "   
+ aRef.RuntimeVersion);  
}  

适用于