Reputation: 79
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.
Upvotes: 0
Views: 31