Implementing ISupportErrorInfo on a C# object exposed to COM

醉酒当歌 提交于 2019-12-24 00:34:00

问题


I'm writing a COM object in C# and I'd like to raise errors to vba/asp client software using the mechanism it understands - the Err object.

In good ol' days that would have meant implementing ISupportErrorInfo on the COM object but I can't find any information about how to implement that interface in a C# object.

Can anybody help?

thanks!


回答1:


You should be able to simulate this by throwing a custom exception from the Managed code. All CCW's automatically implement ISupportErrorInfo (Reference) and understand how to return error information for a thrown exception.

All you need to do is create a custom exception (if a current one does not suite you) and provide the appropriate HResult by setting the base Exception.HResult member.



来源:https://stackoverflow.com/questions/715073/implementing-isupporterrorinfo-on-a-c-sharp-object-exposed-to-com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!