views:

94

answers:

0

Hello, I created an AddIn for Visual Studio, which should handle the case when the user debugs an application and an unhandled exception is thrown. I registered the events "OnExeceptionNotHandled" and "OnExceptionThrown" using the "Events" property of the application object. In the documentation one can read that these events get fired before the "OnEnterBreakMode". But when I debug a simple application which throws an "ArgumentException" the events do not get fired. Here's my code (shortened):

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;

}