How to handle exceptions in C # DLL loaded by C ++

I have a DLL created in C # in order to provide a COM interface to a third-party C # library. I have a C ++ program that uses this COM interface so that it can communicate with the C # library. Sometimes exceptions are thrown on the C # side, and all I return on the C ++ side is HRESULT from the COM call, which means “exception occurred” (or something like that). Is there a way to get all the exception information so that I can print an informative message in my C ++ application log? If not, is there anything I can do on the C # side to catch all exceptions before they trigger any mechanism that HRESULT returns in C ++ so that I can register them on the C # side?

+4
source share
1 answer

Managed exception with HRESULT is displayed. Refer to the table in this MSDN ..NET article to retrieve error information from a COM object using IErrorInfo. This may work well and vice versa. It’s worth taking a picture.

+4
source

All Articles