none
Many Visual studio events missing from Events.SolutionEvents

    Question

  • Hi,

    There are many events missing from SolutionEvents object. Any idea how to handle events such a Solution- "Save, Create, Rebuild all" etc?

    thanks

    Sunday, April 11, 2010 10:41 AM

Answers

  • Hi KalliMan,

    Thanks for your post.

    Events.SolutionEvents just provides events for changes to a solution. If you want to get other Visual Studio Events such as New Project, Save or Rebuild Solution, you can use DTE.Events.get_CommandEvents() to get these Events. Take Save command in Visual Studio for example:

    CommandEvents saveEvents;
    saveEvents =  _applicationObject.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 331);
    saveEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(saveEvents_BeforeExecute); 

    And "{5EFC7975-14BC-11CF-9B2B-00AA00573819}" and 331 are the GUID and CmdID of Save command (File.SaveSelectedItems). About how to get the GUID and CmdID of command, please refer to Dr eX's blog:

    http://blogs.msdn.com/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

    If I misunderstood you, or you have any comments, please feel free to let me know.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, April 12, 2010 6:12 AM

All replies

  • Hi KalliMan,

    Thanks for your post.

    Events.SolutionEvents just provides events for changes to a solution. If you want to get other Visual Studio Events such as New Project, Save or Rebuild Solution, you can use DTE.Events.get_CommandEvents() to get these Events. Take Save command in Visual Studio for example:

    CommandEvents saveEvents;
    saveEvents =  _applicationObject.Events.get_CommandEvents("{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 331);
    saveEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(saveEvents_BeforeExecute); 

    And "{5EFC7975-14BC-11CF-9B2B-00AA00573819}" and 331 are the GUID and CmdID of Save command (File.SaveSelectedItems). About how to get the GUID and CmdID of command, please refer to Dr eX's blog:

    http://blogs.msdn.com/dr._ex/archive/2007/04/17/using-enablevsiplogging-to-identify-menus-and-commands-with-vs-2005-sp1.aspx

    If I misunderstood you, or you have any comments, please feel free to let me know.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, April 12, 2010 6:12 AM
  • See also:

    HOWTO: Capturing commands events from Visual Studio .NET add-ins.
    http://www.mztools.com/resources_vsnet_addins.aspx

    HOWTO: Getting Project and ProjectItem events from a Visual Studio .NET add-in.
    (same link)

    HOWTO: Performing some action before or after a build from a Visual Studio macro or add-in
    (same link)

    HOWTO: Initializing new events in Visual Studio macros
    (same link)

    PRB: CodeModelEvents not firing events in a Visual Studio add-in
    (same link)

    and if you use C# be aware of:

    PRB: Visual Studio .NET events being disconnected from add-in.
    (same link)


    MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/
    Monday, April 12, 2010 8:28 AM
    Moderator
  • Hi Nancy,

    Thank you for your quick answer. It is going to be very helpful to me. But one question remain: Are

    {5EFC7975-14BC-11CF-9B2B-00AA00573819} and 331 
    

    same in all Visual studios? I.e. do I need to check what are the command GUIDs every time when MS releases a new Visual Studio?

     

    Regards

    Monday, April 12, 2010 11:27 AM
  • Hi KalliMan,

    Yes, it's the same in all Visual Studios. Each available command, command group, and menu is identified by a unique GUID:ID pair in Visual Studio.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Monday, April 12, 2010 2:50 PM
  • What is the equlivant of the line below in VB.NET

    saveEvents.BeforeExecute += new _dispCommandEvents_BeforeExecuteEventHandler(saveEvents_BeforeExecute);

    The += syntax does not work between an object and an EventHandler.

     

    Sunday, July 04, 2010 4:05 AM
  • AddHandler saveEvents.BeforeExecute, AddressOf _dispCommandEvents_BeforeExecuteEventHandler
    VB6, VB.NET 2K5
    Thursday, October 28, 2010 11:05 PM