Skip to content

How to start an extension project in visual studio to capture Debug.Start and Debug.StartWithoutDebugging events #411

Answered by RobertvanderHulst
Ncerna asked this question in Q&A
Discussion options

You must be logged in to vote

What I did is this:

  • create a class that implements IVsDebuggerEvents
  • get the debugger object with the help from the VS class inside the toolkit (must be done on the main thread)
await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();
m_debugger = await VS.GetServiceAsync<SVsShellDebugger,IVsDebugger>();
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hr);
  • register the class as event handler
    hr = m_debugger.AdviseDebuggerEvents(this, out m_Debuggercookie);

  • get the initial value of the debugger 'state'

DBGMODE[] modeArray = new DBGMODE[1];
hr = m_debugger.GetMode(modeArray);
  • The event handler looks like this
public int OnModeChange(DBGMODE dbgmodeNew)
{
   XSettings…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
4 replies
@Ncerna
Comment options

@RobertvanderHulst
Comment options

@Ncerna
Comment options

@Ncerna
Comment options

Answer selected by Ncerna
Comment options

You must be logged in to vote
1 reply
@Ncerna
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants