You should not attach an event to the document or one of its objects until the document has completed loading. The earliest you should call this method is in the WebBrowser.DocumentCompleted event of the System.Windows.Forms.WebBrowser control.
This method allows you to attach handlers to unmanaged DOM events not exposed by System.Windows.Forms.HtmlDocument. For more information about available unmanaged DOM events, see Accessing Unexposed Members on the Managed HTML Document Object Model and the IHTMLDocument interfaces: tp://go.microsoft.com/fwlink/?LinkId=104882, tp://go.microsoft.com/fwlink/?LinkId=104884, tp://go.microsoft.com/fwlink/?LinkId=104886, tp://go.microsoft.com/fwlink/?LinkId=104887, tp://go.microsoft.com/fwlink/?LinkId=104888.