I've written a BHO based on this tutorial: http://www.codeproject.com/KB/cs/Attach_BHO_with_C_.aspx
My GetSite
and SetSite
are identical to the tutorials listing. I am adding/removing an OnDocumentComplete
handler and assigning SHDocVW.WebBrowser webBrowser
inside the IObjectWithSite
SetSite function
for debugging purposes I've removed all but basic functionality. Here is my OnDocumentComplete
handler.
public void OnDocumentComplete(object pDisp, ref object URL)
{
if (true)
{
HTMLDocument document;
document = (HTMLDocument)webBrowser.Document;
/*need to do some stuff here to the doc*/
//then free up script references somehow?
}
return;
}
When I attach my VS2008 debugger to an IE instance, I notice all loaded .js are sticking around after their respective windows/tabs are closed. If I set the conditional in OnDocumentComplete to false (or disable my BHO) the leak goes away. Is there more cleanup I need to do on the mshtml.HTMLDocument? Thanks!