views:

205

answers:

5

I have a DLL with some COM objects. Sometimes, this objects crashes and register an error event in the Windows Event Log with lots of hexadecimal informations. I have no clue why this crashes happens.

So, How can I trace those COM objects exceptions?

+2  A: 

The first step is to lookup the Fail code's hex value (E.G. E_FAIL 0x80004005). I've had really good luck with posting that value in Google to get a sense of what the error code means.

Then, I just use trial and error to try to isolate the location in code that's failing, and the root cause of the failure.

Jay Mooney
A: 

I've never found a decent way of looking up the hex codes other than Google. Even then, the codes are reused in so many products that it tends to be more of a guessing game as to which of the "explanations" is the correct one.

+1  A: 

If you just want a really quick way to find out what the error code means, you could use the "Error Lookup" tool packaged with Visual Studio (details here). Enter the hex value, and it will give you the string describing that error code.

Of course, once you know that, you've still got to figure out why it's happening.

Matt Dillard
+1  A: 

A good way to look up error (hresult) codes is HResult Plus or welt.exe (Windows Error Lookup Tool).

I use logging internally in the COM-classes to see what is going on. Also, once the COM-class is loaded by the executable, you can attach the VS debugger to it and debug the COM code with breakpoints, watches, and all that fun stuff.

Nick
+1  A: 

COM objects don't throw exceptions. They return HRESULTs, most of which indicate a failure. So if you're looking for the equivalent of an exception stack trace, you're out of luck. You're going to have to walk through the code by hand and figure out what's going on.

Brad Wilson