Visual Studio Developer Center > Visual Studio Forums > Visual Studio Extensibility > SDK Package: wanting to subscribe to the c# debugger onBreakPointHit event
Ask a questionAsk a question
 

AnswerSDK Package: wanting to subscribe to the c# debugger onBreakPointHit event

  • Saturday, March 21, 2009 10:00 PMRichard Wilburn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    I am trying to work out how to get my vspackage to subscribe to an event that is triggered when the debugger has hit a break point. I am having issue with researching this as most material seems to assume you are making your own debugger. I am trying to create a new visualization for the stack trace window for C# written in C#. I gather i need to interact with the session debug manager?

    I also gather I have to use Package.GetService(Type t) method to obtain a relevant service, but which one?

    I am using VS2008

    Thanks,
    Richard

Answers

All Replies

  • Wednesday, March 25, 2009 10:29 AMNancy ShaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    Hi Richard,

    As far as I know, you could use DebuggerEvents object to achieve this, the OnEnterBreakMode Event will be fired when entering  break mode. For more information, see DebuggerEvents Object Properties, Methods, and Events.

    If I misunderstand you, or you have any problem, please feel free to tell me.

    Hope this helps,
    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.
  • Thursday, March 26, 2009 9:15 AMRichard Wilburn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks for the reply, The information you have provide has been very helpful however I cannot get the event to behave as expected.

    I have subscribed to the following event:

    dte.Events.DebuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;

    but the event is never invoked. Do I need to do anything (in terms of code) in  order to attach to it?
  • Friday, March 27, 2009 3:17 AMNancy ShaoMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Richard,

    As far as I know, your expression is right, it's not necessary to add some special to do it. There is a example with C# language in MSDN, I would suggest you  refer to this example in following link:
    http://msdn.microsoft.com/en-us/library/envdte.debuggereventsclass.onenterbreakmode(VS.80).aspx

    Good luck!
    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.
  • Friday, March 27, 2009 6:02 AMRichard Wilburn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Nancy,

    The example that you have linked to would appear to be for an Addin type project. I am making a VSPackage type project. I believe this is why the event is not being fired.

    I think this link might address the issue, I am now having: http://social.microsoft.com/Forums/en-US/vsx/thread/1b370261-64d6-44b8-b71d-27c76fb0f706 . That link suggests that the garbage collector will collect the event if it is not associated with the vspackage object. I was using the getservice() from outside of the vspackage object so this could be the culprit.

    Thanks for your help :D
  • Friday, March 27, 2009 7:03 AMRichard Wilburn Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    This issue was resolved by making the debuggerevents object a classwide variable in the plugin class