Understanding Error Handling in COM Interop

COM Interop supports error handling from .NET to COM and from COM to .NET. Each HResult in COM is mapped to a .NET exception. Hence, if an exception is thrown in a .NET source, the CCW maps the exception to an HResult using the ISupportErrorInfo interface, which results in an Err object being created in VB6. If a VB6 COM source raises an error, the RCW converts the VB6 COM HResult into a .NET exception, and the mapped exception is thrown in .NET. Check out the VS .NET help topic ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconhresultsexceptions.htm for a complete mapping between HResult values and .NET exception classes.

Get Visual Basic® .NET Power Coding now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.