Hi,
I have a COM-.NET exception handling problem and I would appreciate your help.
I have a COM server that “throws exception” from time to time (the COM
object implements ISupportErrorInfo and generates IErrorInfo objects upon
errors).
The IErrorInfo object that is generated by my COM server extends the
interface IErrorInfo by adding some additional properties (for example:
MoreDetails) – let’s say the name of the extended interface is IMyErrorInfo
(which inherits from IErrorInfo).
Up until now, my COM client caught the “exception” (AKA IErrorInfo) and
checked if it’s of type IMyErrorInfo. If that was the case – my client cast
the IErrorInfo object to IMyErrorInfo and read the additional properties.
Now I’m re-writing my COM client to a .NET code.
.NET maps the IErrorInfo object to COMException and I have no way to get my
additional properties. In other words I have no way to get IMyErrorInfo.
Is there a good way to bypass this problem? Is there a way to get the
IErroInfo object “thrown” by my COM server?
I would appreciate any help you can give.
Thanks,
Michael Phillips, Jr. - 16 Jan 2007 17:16 GMT
Try using Marshal.GetHRForException in your catch block with the
COMException.
This method sets up an IErrorInfo Object that you can obtain by calling
GetErrorInfo.
I am not sure that using QueryInterface on this object will give you your
extended IMyErrorInfo but you can certainly try it.
> Hi,
>
[quoted text clipped - 26 lines]
>
> Thanks,