Search code examples
c++visual-studio-2008exceptionhresult

HRESULT exception not caught in VS 2008


I've got a stange situation in visual studio 2008 C++. I work on code that was originally written for visual studio 2003, where everything works well. Now, ported to VS 2008, the exception handling, which unfortuantely exists widely in the code, does not work anymore. standard code example:

 try
 {
      HRESULT hr = S_OK;
      // do stuff...
      if( FAILED( hr ) ) 
          throw hr;
 }
 catch( HRESULT hr )
 {
      // error handling, but we never get here
 }
 catch( ... )
 {
      // ... not even here
 }

Under VS 2008, no exception is encountered, but I get a crash somewhere else, indicating that the stack pointer must be screwed up. Did anybody come across this behaviour? Any help is appreciated.


Solution

  • After starting the debugger, go to Debug / Exceptions, and select for which exceptions the debugger should stop when the exception is thrown.