COMException in C# when hooking into event

拈花ヽ惹草 提交于 2019-12-05 07:32:51

The problem was the interface for the events was no registered. Once I added the registry key for the Events Interface, this resolved the problem. I was able to get the interface id information using OLEViewer.exe

The error code you got is CONNECT_E_CANNOTCONNECT, something that Googles well. It indicates that the COM server isn't happy about your attempt to subscribe an event handler. Why it is not is something you'll need to find out. Getting help from the component author or vendor is almost always required.

One thing you can try is to look at the type library with Oleview.exe and find out if the event you're trying to subscribe to is on a dispinterface that's marked as the default source interface. If it is not, try casting the object to the dispinterface type, then subscribe to its event.

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