Calls to an OLE Object Should Not Be Done from DllMain

Last reviewed: October 31, 1995
Article ID: Q138812
The information in this article applies to:
  • The Microsoft OLE libraries included with:

        - Microsoft Windows NT version 3.51
        - Microsoft Windows 95
    

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 reference words: COM hang respond
KBCategory: kbole kbprg
KBSubcategory: LeTwoArc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 31, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.