Search code examples
debuggingcomvstooffice-interophresult

Debugging COM Interop HResult codes (VSTO)


I have an Excel add-in firing an HRESULT 0x800401A8 error, when calling the getter of Worksheet.Parent.

I would be glad if anyone could let me know what the error might be, but more importantly and more generally, I would like to know how I can understand these HResult codes?

I did the following but am still confused:


Solution

  • I don't think understanding the structure will help you much.

    The most basic information is that

    • success is indicated by S_OK = 0
    • success may also be indicated by S_FALSE = 1
    • all negative numbers are errors

    There is an "Error Lookup" tool from Microsoft, which is still in the Visual Studio Tools menu, but it looks like it hasn't been updated for about 20 years.

    enter image description here

    Honestly, the best way to find details is to google the hex number, or to search directly in Stack Overflow.


    Edit

    For me, the command is in the tools menu

    enter image description here

    This may be related to the options that I selected in the Visual Studio Installer. Among several other options, I have selected the workload "Desktop development in C++".

    It looks like you can download it here:

    https://www.microsoft.com/en-us/download/details.aspx?id=100432

    but I have not tried out that link.