hey guys, im looking for some information on how to handle exceptions within a C# client from a C++ COM server. I'm use to error handling in C++ and am not quite sure what to do with being able to say SUCCEEDED or have the HRESULT available to me. how do i manage this in C#? anyone know?
p.s sorry if this should be in the C# section, but it is a bit of both worlds.
S_FALSE, S_OK, and S_* in general are success return codes.
E_FAIL, E_POINTER, and E_* in general are error return codes.
An Error returned by a Native C++ COM Server will throw an exception in the C# client.
Success (even if S_FALSE) will not.
Attached is a sample ATL C++ COM Server accessed by a C# client.
Should you return E_FAIL in CDialogInterface::Show (exposed via IDialogInterface), you will get an unhandled exception - one that needs to be handled via the technique in the previous post.
In general, the sample displays a Dialog implemented in a C++ COM Server invoked via a C-Sharp client.
Detailed explanation of the sample is in my post here.
(Ah, it seems that you have already seen it!)
On a side note - in C++, the macro SUCCEEDED returns TRUE for S_FALSE as well - reason being that S_FALSE is also a return code implying SUCCESS.
Last edited by Siddhartha; September 29th, 2005 at 06:43 AM.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.