共用方式為


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
傳回的字串會視參考型別而定。

參考型別

傳回值

Assembly

組件名稱,是無副檔名的參考檔名。

COM

參考型別程式庫的包裝函式名稱,是無副檔名的檔名。

備註

這個屬性會指定參考組件的 .NET Framework 名稱,無論組件是 .NET Framework 組件或是 COM 型別程式庫的包裝函式皆同。

範例

此範例會顯示開啟之 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)
    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 命名空間