Wiring Events manually in Interop

I'm trying to wire up events so that my interop class implimentations can fire events in code.  I can do it using the mshtml from MS, but I can't get it to work when I impliment it and I don't know what the difference.

What I'm doing is just writting the interface like so:

[ComVisible(true), Guid("3050f613-98b5-11cf-bb82-00aa00bdce0b"), 
TypeLibType(TypeLibTypeFlags.FDispatchable), 
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
public interface HTMLDocumentEvents2 {

[DispId(HTMLConsts.DISPID_HTMLDOCUMENTEVENTS2_ONACTIVATE)][PreserveSig]
void OnActivate([MarshalAs(UnmanagedType.Interface)] IHTMLEventObj pEvtObj);


I impliment the interface on my main HTMLDocument class, and tell it to start working like so:

UCOMIConnectionPointContainer icpc = (UCOMIConnectionPointContainer) m_document;
icpc.FindConnectionPoint(ref guid, out m_ConnectionPoint);
m_ConnectionPoint.Advise(this, out m_ConnectionPointCookie);


Where GUID = typeof(HTMLAPI.HTMLDocumentEvents2).GUID;

So what am I doing wrong  Or more specifically, what is the autogened mshtml.dll from MS doing that I'm not

Thanks!


Answer this question

Wiring Events manually in Interop

  • Wiring Events manually in Interop