سؤال

In some VC++ code block I am getting following first chance exception -

First-chance exception at 0x77e4bef7 in myapp.EXE: Microsoft C++ exception: ComUtil::ComError at memory location 0x0013ee04..

I can see the above exception in Output window of Visual studio. How can I catch this exception. I am using Visual studio 2008 for development.

هل كانت مفيدة؟

المحلول

It is just a debugger notification and doesn't otherwise mean anything. You catch the exception like you normally do, just try/catch. You want catch (_com_error& ex) in this case, it tells you why your COM method call failed.

"First chance" exceptions are useful because you can ask the debugger to stop when the exception is thrown. Which lets you find out why it is thrown. You use Debug + Exceptions, tick the Thrown checkbox for C++ exceptions. Not terribly interesting in the case of _com_error exceptions, you'll just see the auto-generated wrapper you got from the #import directive. If you don't want to see the noise of the notification then simply right-click the Output window and untick "Exception messages".

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top