2010-01-01 5 views
1

사용자가 응용 프로그램을 디버깅하고 처리되지 않은 예외가 발생하는 경우를 처리해야하는 Visual Studio 용 AddIn을 만들었습니다. 응용 프로그램 개체의 "이벤트"속성을 사용하여 "OnExeceptionNotHandled"및 "OnExceptionThrown"이벤트를 등록했습니다. 문서에서 "OnEnterBreakMode"전에 이러한 이벤트가 시작된다는 것을 읽을 수 있습니다. 하지만 "ArgumentException"을 throw하는 간단한 응용 프로그램을 디버깅 할 때 이벤트가 발생하지 않습니다. 내 코드는 다음과 같습니다 (축약 됨) :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; 

} 
+0

나는 정확히 같은 문제에 봉착를, 나는 이벤트 중 하나 화재에 도착하지 못할 :( –

답변

0

잘 모르겠지만 기본 클래스의 메소드를 재정의해야 할 수도 있습니다.

1

이 이벤트는 Tools/Options/Debugging/General/Enable the exception assistant이 비활성화 된 경우에만 발생합니다. 이 설정은 기본적으로 사용됩니다.

0

어시스턴트를 프랭크 코치 (Frank Koch)가 제안한대로 해제해야했습니다. Tools/Options/Debugging/General/Enable the exception 도우미가 사용 중지되었습니다.

나는 또한 이벤트에게 길 this MSDN article describes 엮은 :

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) 
{ 
    _applicationObject = (DTE2)application; 
    _addInInstance = (AddIn)addInInst; 

    Globals globals; 
    globals = _applicationObject.Solution.Globals; 

    _debuggerEvents = globals.DTE.Events.DebuggerEvents; 

    _debuggerEvents.OnEnterBreakMode += new _dispDebuggerEvents_OnEnterBreakModeEventHandler(BreakHandler); 
    _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) 
{ 
    Debug.WriteLine("NotHandled\n"); 
} 

void _debuggerEvents_OnExceptionThrown(string ExceptionType, string Name, int Code, string Description, ref dbgExceptionAction ExceptionAction) 
{ 
    Debug.WriteLine("Thrown\n"); 
}