Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email firstname.lastname@example.org
From: Grissom, Ed (egrissomZIIMAGING.COM)
Date: Tue Dec 18 2001 - 15:25:58 CST
The documentation for LoadLibrary and FreeLibrary mention a "module
reference count" that is incremented or decremented appropriately when these
functions are called.
How does this relate to COM reference counts and DllCanUnloadNow() ?
My guess is that they are basically unrelated, except that if the COM
reference count goes to zero, and DllCanUnloadNow() returns S_OK, then
FreeLibrary is called by COM which decrements the "module reference count".
If this "module reference count" is now zero, then the dll is unloaded.
Is my understanding essentially correct ?
If LoadLibrary is used explicitly by a client, will the DLL stay loaded
after all references are Release(d) and DllCanUnloadNow() returns S_OK ?
We are trying to unravel a bug and are in the midst of some finger-pointing
that some clarity on this issue might resolve.
Basically, we have a server DLL that not only contains several COM objects,
but also some non-COM functions that are accessed thru
LoadLibrary/GetProcAddress. All the COM objects seem to correctly handle
the global DLL refcount (used by DllCanUnloadNow) as well as their own
refcount (currently verified only by code inspection). The GetProcAddress
functions do not mess with either object refcounts or the global DLL
The problem comes about when a COM-client of the server described above uses
the LoadLibrary/GetProcAddress to get and use one of the non-COM functions.
The process then runs for quite a while (hours) doing mostly file I/O. When
it is done, it pops up a VB dialog with the client (an ActiveX control)
embedded on it. If this form sits on the users screen untouched for 12
minutes, the app crashes. If the user gets to the form before the 12
minutes are up, the process can continue and eventually completes
If we modify the server so that DllCanUnloadNow always returns S_FALSE, the
form can stay up for hours and everything works properly, i.e. we never see
However, this "solution" is causing other problems, and we would like to
have DllCanUnloadNow function in the proper way.
FYI: The server is an explorer namespace extension, and the fact that it
never unloads makes setup a nightmare. The first install goes fine, but
after that, the dll is always in use, so it cannot be updated. Even after
rebooting, explorer comes up and loads the dll before the "RunOnce" copying
is done, so even a reboot does not solve the setup problem.
Thanks for any thoughts, advice or pointers to more info...
-- ed grissom egrissomziimaging.com
---------------------------------------------------------------- Users Guide http://discuss.microsoft.com/archives/mailfaq.asp contains important info. Save time, search the archives at http://discuss.microsoft.com/archives/index.html . To unsubscribe, mailto:DCOM-signoff-requestDISCUSS.MICROSOFT.COM