共用方式為


VSProjectEvents2.ReferencesEvents 屬性

取得可用來存取 References 集合事件的 ReferencesEvents 物件。

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

語法

'宣告
ReadOnly Property ReferencesEvents As ReferencesEvents
ReferencesEvents ReferencesEvents { get; }
property ReferencesEvents^ ReferencesEvents {
    ReferencesEvents^ get ();
}
abstract ReferencesEvents : ReferencesEvents with get
function get ReferencesEvents () : ReferencesEvents

屬性值

類型:ReferencesEvents
傳回 ReferencesEvents 物件。

備註

ReferencesEvents 屬性可用來存取三個事件:ReferenceAddedReferenceChangedReferenceRemoved

範例

這個範例會使用 ReferencesEvents 屬性,連接特定專案的事件處理方法。 如需如何執行巨集範例的詳細資訊,請參閱 如何:編譯和執行 Automation 物件模型程式碼範例

在執行此巨集之前開啟 Visual Basic 或 Visual C# 專案。

' Macro Editor
' Connects trivial methods to the ReferenceAdded and ReferenceDeleted
' events of the first project in the solution.
Imports VSLangProj
Imports VSLangProj80
Sub ConnectEvents()
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
   Dim refEvents As ReferencesEvents = vsproj.Events.ReferencesEvents
   AddHandler refEvents.ReferenceAdded, AddressOf ReferenceAdded
   AddHandler refEvents.ReferenceRemoved, AddressOf ReferenceRemoved
   AddHandler refEvents.ReferenceChanged, AddressOf ReferenceChanged
End Sub

Sub ReferenceRemoved(ByVal removedRef As Reference)
   MsgBox("The reference for " & removedRef.Name & " was removed.")
End Sub

Sub ReferenceChanged(ByVal removedRef As Reference)
   MsgBox("The reference for " & removedRef.Name & " was changed.")
End Sub

Sub ReferenceAdded(ByVal addedRef As Reference)
   MsgBox("The reference for " & addedRef.Name & " was added.")
End Sub

.NET Framework 安全性

請參閱

參考

VSProjectEvents2 介面

VSLangProj80 命名空間