我爲Visual Studio創建了一個AddIn,它應該處理用戶調試應用程序並引發未處理的異常時的情況。我使用應用程序對象的「Events」屬性註冊了「OnExeceptionNotHandled」和「OnExceptionThrown」事件。在文檔中,可以看到這些事件在「OnEnterBreakMode」之前被觸發。但是當我調試引發「ArgumentException」的簡單應用程序時,事件不會被解僱。這裏是我的代碼(縮短):處理Visual Studio 2008的調試器事件
public class Connect : IDTExtensibility2
{
public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
_applicationObject = (DTE2)application;
_addInInstance = (AddIn)addInInst;
_debuggerEvents = _applicationObject.Events.DebuggerEvents;
_debuggerEvents.OnExceptionThrown += new _dispDebuggerEvents_OnExceptionThrownEventHandler(_debuggerEvents_OnExceptionThrown);
_debuggerEvents.OnExceptionNotHandled += new _dispDebuggerEvents_OnExceptionNotHandledEventHandler(_debuggerEvents_OnExceptionNotHandled);
}
void _debuggerEvents_OnExceptionNotHandled(string ExceptionType, string Name, int Code, string Description, ref dbgExceptionAction ExceptionAction)
{
m_panOutput.OutputString("NotHandled\n");
}
void _debuggerEvents_OnExceptionThrown(string ExceptionType, string Name, int Code, string Description, ref dbgExceptionAction ExceptionAction)
{
m_panOutput.OutputString("Thrown\n");
}
void _debuggerEvents_OnEnterBreakMode(dbgEventReason Reason, ref dbgExecutionAction ExecutionAction)
{
m_panOutput.OutputString("EnterBreakMode\n");
}
DebuggerEvents _debuggerEvents;
}
,我不能讓事件火災要麼:( – 2012-02-13 01:15:33