共用方式為


VSProjectEvents2.VSLangProjWebReferencesEvents 屬性

取得可用來存取 Web 參考事件的 VSLangProjWebReferencesEvents 物件。

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

語法

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

屬性值

型別:VSLangProj80.VSLangProjWebReferencesEvents
VSLangProjWebReferencesEvents 物件。

範例

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

先開啟 Visual Basic、Visual C# 或 Visual J# 專案,再執行這個巨集。

' Macro code.
' Connects trivial methods to the OnAfterWebReferenceAdded,
' OnBeforeWebReferenceRemoved, and OnWebReferenceChanged
' events of the first project in the solution.
' The first project is a Visual Basic, C#, or J# rpoject.
Imports VSLangProj
Imports VSLangProj80
Sub ConnectWebEvents()
    Dim proj As Project = DTE.Solution.Projects.Item(1)
    Dim vsproj As VSProject2 = CType(proj.Object, VSProject2)
    Dim refEvents As VSLangProjWebReferencesEvents = _
    vsproj.Events2.VSLangProjWebReferencesEvents
    AddHandler refEvents.OnAfterWebReferenceAdded, _
    AddressOf WebReferenceAdded
    AddHandler refEvents.OnBeforeWebReferenceRemoved, _
    AddressOf WebReferenceRemoved
    AddHandler refEvents.OnWebReferenceChanged, _
    AddressOf WebReferenceChanged
End Sub
Sub WebReferenceRemoved(ByVal removedRef As Object)
    MsgBox("The reference for " & removedRef.Name & " was removed.")
End Sub
Sub WebReferenceChanged(ByVal changedRef As Object)
    MsgBox("The reference for " & changedRef.Name & " was changed.")
End Sub
Sub WebReferenceAdded(ByVal addedRef As Object)
    MsgBox("The reference for " & addedRef.Name & " was added.")
End Sub

.NET Framework 安全性

請參閱

參考

VSProjectEvents2 介面

VSLangProj80 命名空間

其他資源

HOW TO:回應 Web 參考事件 (Visual Basic)

HOW TO:回應 Web 參考事件 (Visual C#)