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 (IE11) when used as a Virtual Machine. However, the same BHO works fine on physical machines and also on Windows 8.1 (IE11) both Physical and Virtual Machine.

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
  • I found that you have asked a [same question](https://stackoverflow.com/questions/62829660/ie-crashing-when-exposing-methods-for-js) before. I suggest that you can focus on one thread and delete the duplicate one so that it won't confuse us. Besides, I suggest that you can test on a real Windows 10 machine to see if the issue still persists. – Yu Zhou Aug 18 '20 at 01:52
  • @YuZhou I have tested it on physical machines and it works fine there. – Usama Mohsin Aug 18 '20 at 13:07
  • If it works fine in physical machines then I think it should be no problem with your BHO. Maybe there're some environment settings different from the real environment. I think the test results in physical machines are more accurate than that in VM. – Yu Zhou Aug 20 '20 at 05:54

0 Answers0