Darren Ford AUS

Hi all,

I am currently working on a web-based application that mimics our non-web-based application and have come acrosss a stumbling block. The application requires an icon in the system tray that, when clicked, changes the content in the main application.

I've been (attempting to) write an Active-X control (using ATL) that places an icon in the system tray, which when clicked, changes the URL of the current page in the web app.

I've created a top-level frameset, which contains two frames (one to hold the invisible Active-X control (A) and the other containing the application content (B)). What I'm trying to do is, when the icon is clicked in the system tray, changes the URL in frame B to a 'home' page.

I originally attempted this using event callbacks from my ActiveX control to the javascript code in (A) which then used the DOM to change the URL for frame B (phew!). All seems fine, however after a couple of successful clicks where everything appears to work perfectly, IE dies way down in MSHTML.dll/jscript.dll/ntdll.dll. The event viewer shows error event 1000 which is not very useful.

I've kept my code as simple as possible at this stage, and as such can't see any issues with memory or resources (I've run it through Boundschecker as well, and it doesn't detect any wrongdoing, athough at times BC can be a bit misleading!).  I'm concerned that there may be an issue with an ActiveX control modifying a URL in the active document, but haven't had any luck with my search on the web.

Does anyone have any suggestions or advice on what I could do to solve this Or am I approaching this from the wrong angle Should I be using the IHTMLDocument interfaces to find frame B and set the URL that way

Cheers and many thanks,


Re: Internet Explorer Extension Development IE 6/7 crashing with ActiveX event callback to javascript


I'm seeing something similar on Vista+IE7 when closing a page (i.e., navigating to a new one) when the page contains an ActiveX object. I'm not sure if said object is in the middle of a callback into the web page. Sometimes the stack trace is all ntdll, jscript, mshtml, etc. In one case, there is an instance of my object's QueryInterface function. No problems on IE6 (or even IE7 on WinXP, I think). IE protected mode is off (or ActiveX object doesn't work at all if protected mode is on).

Nasty. We're fixing to give up on getting this working on Vista.


Re: Internet Explorer Extension Development IE 6/7 crashing with ActiveX event callback to javascript

Darren Ford AUS

Hi all,

Whilst I haven't found a proper solution to this, I seem to have isolated the point in my code that seems to cause the issue. Knowing this, I've created a workaround which seems to be stable (i.e. it hasn't crashed yet in a day's worth of testing on IE6 and IE7, although I know this could change at any moment :-) I have yet to try it on Vista so I'm crossing my fingers... )

The problem appears when I have a callback into my Active-X object directly after an XMLHttpRequest has returned (regardless of whether I use a synchronous or an asynchronous XMLHttpRequest). I have a timer in my Javascript code that fires off a request to a remote server.

eg. (pseudocode)
change_req = new ActiveXObject(XMLHttpRequest)
change_req. <blah blah>
var result =

It doesn't appear to matter what is in DoTask (it can even just return an S_OK), and frequently it crashes. Even if I pass a dummy result to DoTask (eg. DoTask(1)) it responds in the same way.

I resolved this in my code by having an additional win32 timer in my active-x control that periodically calls back into the javascript to retrieve the result. I store the result of the XMLHttpRequest in a variable, and the callback from the active-x control reads the result from the variable.

Whilst this is not an elegant solution (I hate polling as much as the rest of the dev community) it seems to have bypassed the crash that I was getting and not making any headway at all on. Given that the original crash was become quite a huge concern for us, this work around has at least given us some breathing space until we can find a better solution.

Anyway, I thought I'd share my findings with you all. If anyone has any better ideas, please let me know.

Cheers -- Darren.

Re: Internet Explorer Extension Development IE 6/7 crashing with ActiveX event callback to javascript


Hi Darren

Not quiet sure what your doing but the is sounds like you are experiencing a problem caused by not marshalling interface pointers between threads apartments. Eg Object1 creates Object2 in a new thread with Object 2 using a callback interface passed to it from Object 1 to return information to Object 1. The callback interface needs to be marshalled across the thread apartment boundaries. Use CoMarshalInterThreadInterfaceInStream and CoGetInterfaceAndReleaseStream functions to do this . Tom Armstrongs book ATL Developer's Guide Chapter 10 COM Threading has a good example. BTW IHTMLDocument2 needs to be marshalled exactly the same way if you pass it across thread apartments

Hope this helps