Removing COM dll from memory
-
hi all, i have a dll say abc.dll loaded in memory and i have to unload abc.dll and load another dll of same name but it may differ in version number. i tried to unregister the first dll and register the second dll programatically. but still the code refers to the first dll. I think its because the first dll is still in memory. Am i right? Then how to completely remove the that dll from memory? I also renamed the first dll after unregistering it and then registered the second one. but it doesnt work.
-
hi all, i have a dll say abc.dll loaded in memory and i have to unload abc.dll and load another dll of same name but it may differ in version number. i tried to unregister the first dll and register the second dll programatically. but still the code refers to the first dll. I think its because the first dll is still in memory. Am i right? Then how to completely remove the that dll from memory? I also renamed the first dll after unregistering it and then registered the second one. but it doesnt work.
If you look here: http://msdn.microsoft.com/en-us/library/ms690368(VS.85).aspx[^], you'll see:
MSDN says:
Notes to Callers You should not have to call DllCanUnloadNow directly. OLE calls it only through a call to the CoFreeUnusedLibraries function. When it returns S_OK, CoFreeUnusedLibraries frees the DLL.
You should call CoFreeUnusedLibraries after unregistering it. Also make sure that you have no live COM objects created by the DLL. If not, the DLL will have a reference count > 0, meaning that DllCanUnloadNow will return S_FALSE. It could also be the case that reference counting in the DLL is buggy.
-- Kein Mitleid Für Die Mehrheit