我正在开发一个扩展(VSPackage),我正在订阅 VSPackage.cs 的构造函数中的 2 个调试器事件
public sealed class ComboBoxPackage : Package
{
....
public ComboBoxPackage()
{
Trace.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
_dte = (DTE)Package.GetGlobalService(typeof(DTE));
_events = _dte.Events;
_debuggerEvents = _events.DebuggerEvents;
_debuggerEvents.OnEnterRunMode += _debugEvents_OnEnterRunMode;
_debuggerEvents.OnContextChanged +=_debuggerEvents_OnContextChanged;
}
void _debuggerEvents_OnContextChanged(EnvDTE.Process NewProcess, Program NewProgram, Thread NewThread, EnvDTE.StackFrame NewStackFrame)
{
throw new NotImplementedException();
}
private void _debugEvents_OnEnterRunMode(dbgEventReason Reason)
{
return;
}
}
当我运行它(strating run an application)时,只调用 _debuggerEvents_OnContextChanged,不调用 _debugEvents_OnEnterRunMode。
如果我对 Addin 项目做同样的事情,一切正常。