4

I'm calling a C# COM component using javascript: keystore = new ActiveXObject("RBCrypto.KeyStore");. I've noticed this instance stays around until I exit the browser. Is there anyway to "release" that object when the user leaves the page? Currently i'm using:

window.onunload=function() //when a user leaves the page close the keystore
{
     if(keystore != null)
     {
         try
         {
            keystore.closeKeyStore(); //method in keystore
            delete keystore;
         }
         catch(err) { alert(err.description); }
     }  
}

But the COM object is still hangin around. Any ideas?

Petey B
  • 11,439
  • 25
  • 81
  • 101

2 Answers2

1

try,

keystore.Application.Quit();

This result is from http://www.c-point.com/javascript_tutorial/jsobjActiveXObject.htm

you can also try nulling all the object attached values before delete

for (k in elm) {
            try {
                elm[k] = null;
            }
            catch (e) {
            }
        }
}

I have found this helps in the case of HTML objects that have not been delete, and have various objects attached to them.

WhyMe
  • 535
  • 2
  • 13
1

I know it's a little late to respond. "Before late than never"

I think the correct is "Application.Quit();". However, the Application of object COM/OLE/ActiveX can return null. I do not know how to do return Application != null to run the Quit();

You can try...

try
{
    keystore.closeKeyStore();
    delete keystore;
    keystore = null;
    CollectGarbage(); 
}
catch(err)
{
    alert('freeing ActiveXObject via javascript'+ err.description);
}
Cobaia
  • 1,503
  • 3
  • 22
  • 41