Debugger Events VSIX RRS feed

  • Question

  • Hello,

    I am trying to tie into the debugger. I have my VSIX project open and I debug it. VS opens and I open up my test project. In the test project I run a command wherein the initialize method in the package calls the following:

    private DTE GetDte()
                return ((EnvDTE.DTE)this.GetService(typeof(EnvDTE.DTE)));
            private void LinkContextChangeEvent()
                Events events = this.GetDte().Events;
                DebuggerEvents eventsDebuggerEvents = events.DebuggerEvents;
                EnvDTE.DebuggerEvents debugEvents = eventsDebuggerEvents;
                debugEvents.OnEnterBreakMode +=
                    new _dispDebuggerEvents_OnEnterBreakModeEventHandler(DebugEvents_OnEnterBreakMode);

                debugEvents.OnContextChanged +=
                    new _dispDebuggerEvents_OnContextChangedEventHandler(ContextHandler);
                debugEvents.OnEnterDesignMode += DebugEvents_OnEnterDesignMode;
                debugEvents.OnEnterRunMode += DebugEvents_OnEnterRunMode;


    When I run the test project none of those events are ever hit. At one time they did hit but since then they have not. I suspect there is an issue where I am initializing them at (inside the initialize method of the package).

    Thursday, October 26, 2017 4:14 AM


All replies

  • You should store events and eventsDebuggerEvents as class variables to prevent them from garbage collection.

    Sergey Vlasov | Vlasov Studio | Visual Studio extensions and tools

    • Edited by Sergey Vlasov Thursday, October 26, 2017 9:39 AM
    • Marked as answer by Stumple Wednesday, November 1, 2017 3:23 AM
    Thursday, October 26, 2017 9:39 AM
  • Results are the same. I am still not getting a notification when trying to link into the debugger events. I am missing something because it worked once and never again.

    • Edited by Stumple Wednesday, November 1, 2017 2:08 AM
    Wednesday, November 1, 2017 2:07 AM
  • I figured it out.

    You have to hold onto a reference to the DTE application and also to the events.

    Wednesday, November 1, 2017 3:23 AM