John wrote:
>HResult is not useful in the general case.
To elaborate a bit, nearly all COM methods return an HRESULT and this is
the basis for COM error handling. Some common HRESULT values are here
[1]. For a more complete list, check out the winerror.h include file
that is normally included by a C++ COM project. COM objects are also
allowed to create custom HRESULT values.
When managed code calls into some COM code, it may get back a failing
HRESULT value. If the managed code can't handle the error, then it would
probably wrap the HRESULT up in a .NET exception and throw it. So for
the HResult value in an exception to be much value you'd probably need
to know what the managed code was doing, and what method on what COM
object was being called. Okay, unless it is something truly obvious like
E_OUTOFMEMORY.
And if the error didn't originate in a COM call, then the HResult is
going to be meaningless.
So what is the bigger problem that you're trying to solve?
Cheers,
Stuart
[1] http://msdn.microsoft.com/library/en-us/com/htm/error_899v.asp