Uwe Keim Uwe Keim - 3 months ago 13
C# Question

Closing IActiveScript engine throws E_UNEXPECTED exception

Working with C# in .NET, I am trying to call

on my instance of the Windows Scripting host.

Since I am currently hunting memory leaks, I discovered that I did not call this
Close
method and tried to add the missing code. So I added a call to the
Close
method.

Unfortunately, when calling the
Close
method, a COM exception is thrown with E_UNEXPECTED as the error code.

Querying the script state of the engine before closing it, it returns
SCRIPTSTATE_CONNECTED
.

Question:

How can I gracefully call
IActiveScript.Close
without getting an exception thrown?

Answer

To (partially) answer my own question:

I finally managed to build a stand-alone test application where I successfully can call the IActiveScript.Close method and also have no memory leaks.