Managed COM object not unloading in Sidebar
So I created an ActiveX control in C#. Works great except for one problem, it doesn't unload when the gadget is closed.
I thought it might be something in my gadget that was causing the problem, but I created a gadget that has nothing in it, and it doesn't unload either when the gadget is closed.
I tried the same thing with an ATL C++ control, it unloaded fine when the gadget was closed.
Any ideas, it's really a problem when installing a new version over an old version thats been run at some point in the sidebar's process time.
Dan O'Connell
Try clearing the object as the Gadget closes. If the COM has any dependencies that you need to clear down, add a terminate function to the COM to clean up. This is the technique I use in
Asteroids to closedown DirectSound.
eg.
var myCOM;
function startup() {
myCOM = new ActiveXObject("myClass");
}
function terminate() {
myCOM.terminate();
myCOM = null;
}
...
<BODY onload="startup()" onunload="terminate()">
...
The problem isn't in my code, or code that I can write. I wrote a managed com object that does nothing, created it with an object tag in the html, opened the gadget, and closed the gadget. Never touched the object from javascript, and the com object does not unload. Created a different COM object in C++, same html, just a different CLSID, that com object unloads when the sidebar is closed down.
I'm not sure if it's a bug in .NET or in sidebar, but the managed code does not unload and I want to know if there is anything I can do about it.:-)
Dan
No I do not, I will try thanks, thanks for the tip.
I'll let you know how it turns out.
Dan