Calls to an OLE Object Should Not Be Done from DllMain

ID: Q138812


The information in this article applies to:
  • Microsoft OLE Libraries, included with:
    • Microsoft Windows NT, versions 3.51, 4.0
    • Microsoft Windows 95
    • Microsoft Windows 2000


SUMMARY

OLE operations involving calls to an OLE object should not be done in the DllMain function of a DLL because a deadlock can occur.


MORE INFORMATION

This is because these OLE operations can cause the creation of a background OLE thread (for RPC), and that background OLE thread needs to call into each DllMain in the process. However this thread cannot call the DllMain of the DLL that is doing the OLE operation because DllMain is not re-entrant. Consequently a deadlock occurs. This deadlock always occurs with Windows NT and under certain conditions with Windows 95.

The DLL should do these OLE operations in another function and should export this function so that the DLL client can call the function after the DLL is loaded.

Additional query words: COM hang respond

Keywords : kbole kbprg kbNTOS351 kbNTOS400 kbWinOS2000 kbWinOS95 kbGrpCom kbDSupport
Version : :
Platform :
Issue type :


Last Reviewed: October 22, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.