Hooking IE Events in C#
See the question and my original answer on StackOverflowThis is a threading issue. The Call() call happens on an MTA thread, and you can't access MSHTML from an MTA thread. There are many ways to change this, however, the most simple is to do this:
public void DocumentComplete(object pDisp, ref object URL)
{
var events = (HTMLDocumentEvents2_Event)ie.Document;
events.onclick += (evt) =>
{
MessageBox.Show(string.Format("Event Hooked {0}, Qualifier {1}", evt.type, evt.qualifier));
return false;
};
}