Calls to an OLE Object Should Not Be Done from DllMain

Article translations Article translations
Article ID: 138812 - View products that this article applies to.
This article was previously published under Q138812
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all


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


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.


Article ID: 138812 - Last Review: February 24, 2014 - Revision: 3.1
  • Microsoft OLE 4.0, when used with:
    • Microsoft Windows NT 3.51 Service Pack 5
    • Microsoft Windows NT 4.0
    • Microsoft Windows 95
    • the operating system: Microsoft Windows 2000
kbnosurvey kbarchive kbprogramming KB138812

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from