Daniel Silveira
Daniel Silveira

Reputation: 42543

How to trace COM objects exceptions?

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?

Upvotes: 0

Views: 721

Answers (4)

Brad Wilson
Brad Wilson

Reputation: 70626

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.

Upvotes: 1

Nick
Nick

Reputation: 13424

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.

Upvotes: 1

Matt Dillard
Matt Dillard

Reputation: 14853

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.

Upvotes: 1

Jay Mooney
Jay Mooney

Reputation: 2256

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.

Upvotes: 2

Related Questions