Udostępnij za pośrednictwem


Event Objects (Specific to Types of Projects)

Most of the available event objects specific to Visual C# and Visual Basic are represented as properties on the VSProjectEvents2 object. ProjectItemsEvents and ProjectsEvents objects are also available per project type basis. The following table lists all of the Visual Studio event objects specific to project types. To see the events each object offers, click the link.

Event Objects

Object Name

Description

BuildManagerEvents

Provides events for the build manager.

ImportsEvents

Provides Imports events. Visual Basic only.

ReferencesEvents

Provides events for adding, changing or removing project references.

VSLangProjWebReferencesEvents

Provides events for adding, changing or removing Web references.

ProjectItemsEvents

Provides events for project items. These events are defined for all Visual Studio project types.

ProjectsEvents

Provides events for projects. These events are defined for all Visual Studio project types.

Specifying the Project Type

To retrieve the various project type specific event objects from the automation model, use the following syntax:

' Declaration.
Public WithEvents prjEventHandler As EnvDTE.ProjectsEvents
' Retrieve the event objects from the automation model
prjEventHandler = EnvDTE.Events.GetObject("VBProjectsEvents")
// Declaration.
Private EnvDTE.ProjectsEvents prjEventHandler;
// Retrieve the event objects from the automation model.
prjEventHandler = EnvDTE.Events.GetObject("VBReferencesEvents");

Or

' Declaration
Public WithEvents refEvents As VSLangProj80.ReferencesEvents
' Retrieve the event objects from the automation model.
refEvents = CType(EnvDTE.Events.GetObject("VJSharpReferencesEvents"), _
 VSLangProj.ReferencesEvents)
// Declaration.
private VSLangProj.ReferencesEvents refEvents;
// Retrieve the event objects from the automation model
refEvents = (VSLangProj.ReferencesEvents)
EnvDTE.Events.GetObject("CSharpReferencesEvents");

The name that is passed to GetObject reflects the project type. The table below provides a list of all the project type specific event objects for Visual C# and Visual Basic projects.

Listing of Project Type Specific Event Names

Event Object Name

Description

VBBuildManagerEvents

Returns the BuildManagerEvents object for Visual Basic projects.

VBImportsEvents

Returns the ImportsEvents object for Visual Basic projects.

VBProjectItemsEvents

Returns the ProjectItemsEvents object for Visual Basic projects.

VBProjectsEvents

Returns the ProjectsEvents object for Visual Basic projects.

VBReferencesEvents

Returns the ReferencesEvents object for Visual Basic projects.

CSharpBuildManagerEvents

Returns the BuildManagerEvents object for Visual C# projects.

CSharpProjectItemsEvents

Returns the ProjectItemsEvents object for Visual C# projects.

CSharpProjectsEvents

Returns the ProjectsEvents object for Visual C# projects.

CSharpReferencesEvents

Returns the ReferencesEvents object for Visual C# projects.

These strings can be found in the registry under the key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\<Package GUID>. The Package GUIDs are:

  • 164B10B9-B200-11D0-8C61-00A0C91E29D5 for Visual Basic project system.

  • FAE04EC1-301F-11D3-BF4B-00C04F79EFBC for Visual C# project system.

    Note

    These GUIDs are valid only in Microsoft Visual Studio 2005.

See Also

Concepts

Automation Event Objects

Other Resources

Responding to Events (Visual Basic and Visual C# Projects)

Responding to Automation Events