Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ReferencesEvents Interface

Provides access to events that are raised by adding, deleting, or changing project references. Use this object for functionality and refer to ReferencesEventsClass for this object’s documentation.

Namespace:  VSLangProj
Assembly:  VSLangProj (in VSLangProj.dll)
[GuidAttribute("1CF40C9E-D548-4B45-AD0F-3D7843F62BBB")]
public interface ReferencesEvents : _ReferencesEvents, 
	_dispReferencesEvents_Event

The ReferencesEvents type exposes the following members.

  NameDescription
Public methodadd_ReferenceAddedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public methodadd_ReferenceChangedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public methodadd_ReferenceRemovedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public methodremove_ReferenceAddedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public methodremove_ReferenceChangedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public methodremove_ReferenceRemovedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Top
  NameDescription
Public eventReferenceAddedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public eventReferenceChangedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Public eventReferenceRemovedInfrastructure. Microsoft Internal Use Only. (Inherited from _dispReferencesEvents_Event.)
Top

The ReferencesEvents object may be accessed from either the VSProject object or the DTE object. Each project, through the VSProject object, has a ReferencesEvents object providing access to the events of that project. The ReferencesEvents object of the DTE object may be used to connect to events of individual projects or to events of all Visual Basic projects in the solution.

To connect to the events of a single project using the VSProject object, see ReferencesEvents.

The following two examples use the late-bound VBReferencesEvents property to connect to Visual Basic project events. Use CSharpReferencesEvents to connect to Visual C# events.

There are two late-bound methods for handling events. The first method allows you to connect to events for a particular project and requires the Option Strict Off statement to compile. This method returns an error if the parameter to the VBReferencesEvents call is not of type Project. The parameter to VBImportsEvents is optional. If it is omitted, events for all the Visual Basic projects in the solution are received.

' Macro editor
Imports VSLangProj
Option Strict Off
Dim WithEvents refEvents As ReferencesEvents
Sub ConnectProjectRefEvents()
   ' Must have Option Strict Off
   Dim proj As Project = DTE.Solution.Projects.Item(1)
   refEvents = DTE.Events.VBReferencesEvents(proj)
End Sub

Public Sub refEvents_ReferenceAdded(ByVal pReference _
As VSLangProj.Reference) Handles refEvents.ReferenceAdded
   MsgBox(pReference.Name)
End Sub

The second late-bound method allows you to add event-handling methods for events in all the projects in the solution. This method does not offer a way to filter events for only a particular project. It will compile with Option Strict On.

' Macro editor
Imports VSLangProj
Dim WithEvents refEvents As ReferencesEvents
Sub ConnectAllRefEvents()
   refEvents = CType(DTE.Events.GetObject("VBReferencesEvents"), _
      ReferencesEvents)
End Sub

Public Sub refEvents_ReferenceAdded(ByVal pReference _
As VSLangProj.Reference) Handles refEvents.ReferenceAdded
   MsgBox(pReference.Name)
End Sub
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.