0

I am developing a BHO for IE in C#. The issue I am stuck in is that IE crashes by saying that

"Internet Explorer has stopped working"

then

"A problem with the webpage caused Internet Explorer to close and open the tab again"

This behavior is observed on Windows 10 Pro 2016 and IE 11. However same BHO is working fine on other versions of Windows like Windows 8.1 - IE 11, Windows 10 2019,2020 - IE 11.

This usually occurs on navigating to a link in the already opened tab or on refreshing the page.

I have checked through logs it occurs when exposing methods for JS through BeforeScriptExecute event on this line p.SetValue(windowEx, this);

private void S2_BeforeScriptExecute(object pDispWindow)
{
    try
    {
        HTMLDocument doc = _webBrowser.Document as HTMLDocument;

        if (doc != null)
        {
            IHTMLWindow2 tmpWindow = doc.parentWindow;
            dynamic window = tmpWindow;
            IExpando windowEx = (IExpando)window;
            PropertyInfo p = windowEx.AddProperty("myExtension");
            p.SetValue(windowEx, this);
        }
    }
    catch (Exception ex)
    {
    }
}

The complete code is shared here in the question.

Usama Mohsin
  • 79
  • 1
  • 2
  • 11
  • Mad keen to know why you're putting dev effort into a dead browser; are you serving an industry (medical?) that hasn't upgraded to something from this century? :) – Caius Jard Jul 10 '20 at 07:59
  • We are adding IE support for our product. As many of our clients are still using IE. – Usama Mohsin Jul 10 '20 at 09:24
  • I suggest you to compare the IE settings and IE update versions between the working one and not working one to see if there's any difference. I think this can help to narrow down the issue. As it works well in other versions of Windows, I think the issue is related with the OS environment or IE versions and settings. – Yu Zhou Jul 13 '20 at 08:08

0 Answers0