How to track COM object exceptions?

I have a DLL with some COM objects . Sometimes these objects fail and record an error event in the Windows event log with a lot of hexadecimal data. I do not know why this is happening.

So how can I track COM object exceptions?

0
source share
4 answers

The first step is to search for the hexadecimal value of the Fail code (EG E_FAIL 0x80004005). I was really lucky to post this value to Google to understand what the error code means.

Then, I just use the trial version and the error to try to isolate the place in the code that does not work, and the root cause of the failure.

+2
source

If you just need a very quick way to find out what the error code means, you can use the Error Finder tool packaged in Visual Studio (more info here ). Enter a hexadecimal value and it will give you a string describing this error code.

Of course, once you know this, you still need to find out why this is happening.

+1
source

A good way to find errors (hresult) is to use HResult Plus or welt.exe (Windows Error Finder).

I use logging inside COM classes to find out what happens. In addition, as soon as the COM class is loaded with the executable file, you can attach the VS debugger to it and debug the COM code with breakpoints, clocks and all this interesting stuff.

+1
source

COM objects do not throw exceptions. They return HRESULT, most of which indicate failure. Therefore, if you are looking for the equivalent of an exception stack trace, you're out of luck. You will have to go through the code manually and find out what happens.

+1
source

Source: https://habr.com/ru/post/1286760/


All Articles