Microsoft Developer Network >
Domovská stránka fór
>
Visual Studio Extensibility
>
[MACRO][VS2008] Add a "When Hit" Breakpoint with a macro
[MACRO][VS2008] Add a "When Hit" Breakpoint with a macro
- Hi everyone,I would like to add some breakpoints from my macro. I manage to do this easily thanks to the EnvDte.Breakpoint interface. But I would like to create a "When hit" breakpoint and to associate this breakpoint with a macro (to execute the macro when the breakpoint is reached).I've not found any property/method in the objectmodel to help doing this. Do I miss something ?
Odpovědi
- Hi Patrice,
Base on my understanding, you want to subscribe to an event that is triggered when the debugger has hit a break point. If so, you can try to use DebuggerEvents object to achieve this, the OnEnterBreakMode Event will be fired when entering break mode. Please refer to following code snippet:
// Place the following code in the Exec method of the add-in: EnvDTE.DebuggerEvents debugEvents = applicationObject.Events.DebuggerEvents; debugEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(DebuggerEvents.BreakHandler); // Place the following Event handler code in the add-in: // Needed to activate event handlers in Connect.Exec. public static void StartEvents(DTE dte) { System.Windows.Forms.MessageBox.Show("Events are attached."); } // OnEnterBreakMode Event. public static void BreakHandler(dbgEventReason reason, ref dbgExecutionAction execAction) { System.Windows.Forms.MessageBox.Show("Debugger enters break mode. " + "Reason: " + reason.ToString()); }
For more information, please see this thread: SDK Package: wanting to subscribe to the c# debugger onBreakPointHit event.
If I misunderstood you, or you have any questions, please let me know.
Best Regards,
Nancy
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.- Navržen jako odpověďNancy ShaoMSFT, Moderátor7. července 2009 3:03
- Označen jako odpověďNancy ShaoMSFT, Moderátor8. července 2009 3:01
Všechny reakce
- Hi Patrice,
Base on my understanding, you want to subscribe to an event that is triggered when the debugger has hit a break point. If so, you can try to use DebuggerEvents object to achieve this, the OnEnterBreakMode Event will be fired when entering break mode. Please refer to following code snippet:
// Place the following code in the Exec method of the add-in: EnvDTE.DebuggerEvents debugEvents = applicationObject.Events.DebuggerEvents; debugEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(DebuggerEvents.BreakHandler); // Place the following Event handler code in the add-in: // Needed to activate event handlers in Connect.Exec. public static void StartEvents(DTE dte) { System.Windows.Forms.MessageBox.Show("Events are attached."); } // OnEnterBreakMode Event. public static void BreakHandler(dbgEventReason reason, ref dbgExecutionAction execAction) { System.Windows.Forms.MessageBox.Show("Debugger enters break mode. " + "Reason: " + reason.ToString()); }
For more information, please see this thread: SDK Package: wanting to subscribe to the c# debugger onBreakPointHit event.
If I misunderstood you, or you have any questions, please let me know.
Best Regards,
Nancy
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.- Navržen jako odpověďNancy ShaoMSFT, Moderátor7. července 2009 3:03
- Označen jako odpověďNancy ShaoMSFT, Moderátor8. července 2009 3:01

