Reference3.Name 属性

获取对象的名称。

命名空间:  VSLangProj80
程序集:  VSLangProj80(在 VSLangProj80.dll 中)

语法

声明
ReadOnly Property Name As String
string Name { get; }
property String^ Name {
    String^ get ();
}
abstract Name : string
function get Name () : String

属性值

类型:System.String
返回的字符串取决于引用类型。

引用类型

返回的值

程序集

程序集名称,是没有扩展名的引用文件名。

COM

被引用类型库的包装名称,是没有扩展名的文件名。

备注

该属性指定被引用程序集的 .NET Framework 名称,不论该程序集是 .NET Framework 程序集还是 COM 类型库的包装。

示例

此示例显示打开的 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)
    GetName(applicationObject)
End Sub
Sub GetName(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) 
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;
    GetName(((DTE2)applicationObject));
}
public void GetName(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 name of the first reference in the project 
is: " + aRef.Name);
}

.NET Framework 安全性

请参见

参考

Reference3 接口

Name 重载

VSLangProj80 命名空间