7

I'm trying to develop a BHO for the release preview of IE 10. The BHO needs to be able to allow javascript to call a C# function.

I've followed the instructions available here:

Calling C# BHO methods from Javascript

These instructions work great in IE 9.

Unfortunately, I've found that they only work for the first tab created in IE 10. The second and subsequent tabs do not expose the BHO interface to Javascript. On occasion, new tabs work, but most of the time they do not. Moreover, it fails silently. I'm guessing this has something to do with the process model -- but again, it works fine in IE 9 (which has the same process model).

Here is the specific snippet of code that I'm using:

private void InstallJSObject(IHTMLWindow2 window)
{
    // Install our javascript object
    IExpando windowEx = (IExpando)window;

    PropertyInfo property = windowEx.GetProperty("myBHO", System.Reflection.BindingFlags.IgnoreCase);
    if (property == null)
    {
        property = windowEx.AddProperty("myBHO");
    }
    property.SetValue(windowEx, this, null);
}

Before posting, I researched the following: http://bit.ly/R9qldf

Community
  • 1
  • 1
afourney
  • 1,657
  • 1
  • 12
  • 10
  • 1
    You might want to post this on [Microsoft Connect](http://connect.microsoft.com) as it seems more like a bug for the release candidate (which is still pre-release software) rather than something that's been backed for release. This could very well be "too localized". – casperOne Aug 13 '12 at 18:13
  • 1
    I'm seeing the same problem with the released version of IE10. This problem still exists. – Ryan Morlok Apr 19 '13 at 15:50
  • Well how are you calling InstallObject? If you're following this article: http://www.codeproject.com/Articles/19971/How-to-attach-to-Browser-Helper-Object-BHO-with-C How many times are you getting SetSite called? It should be called once per browser. Also, remember, each tab is a different process so if you're just using the debugger to verify then you'll have to attach to each process. – justin.m.chase May 28 '14 at 14:56

1 Answers1

0
var myATL = new ActiveXObject("MySampleATL.MyClass");

if (myATL.IsBHOInstalled)
       alert (myATL. SayHelloFromBHO());

else
       alert ("BHO isn't installed now !");

window.external.AddFavorite(<url>, "text");

Extracted from here.

The the blog is dated back to April'07, still, may be this is what you were looking for..

Vaibhav
  • 2,527
  • 1
  • 27
  • 31