by Fenton Webb
We are using in-process ActiveX servers. To use the component, we call GetInterfaceObject(). When developing it, we are changing the code and need to load newer version, and to save time, preferably within the same AutoCAD session. Sometimes we can load the new version using GetInterfaceObject() with newer version, but other times it fails.
Is there any method to unload the interface object to load newer version of the component?
The COM unloading mechanism requires that a COM client from "time to time" calls the function CoFreeUnusedLibraries() in order to free up the memory and unload the libraries which are loaded but not used by any client in the system. AutoCAD being a COM client also makes calls to this function but you cannot anticipate the time when this call is being made.
The fact that sometimes you can easily GetInterfaceObject with newer version but sometimes it fails means that the old library is still loaded, and AutoCAD didn't call CoFreeUnusedLibraries() yet.
To solve the problem and unload the old library you only have to make a call to CoFreeUnusedLibraries().
Tip - be sure to check out CoFreeUnusedLibrariesEx() also…