COM application hangs when you call CoCreateInstance from DllMain

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


When you call the CoCreateInstance function from the DllMain function, the Component Object Model (COM) application hangs.


CoCreateInstance may start a thread that tries to call the DllMain function of all dynamic-link libraries (DLLs) that exist in the process by passing a DLL_THREAD_ATTACH value. Because the call originates from DllMain, and because DllMain is not a reentrant function, the call to CoCreateInstance never returns.


To resolve this problem, do not call CoCreateInstance from DllMain. You can move the call to an initialization function or to any other function that is called later.


This behavior is by design.


Article ID: 305723 - Last Review: February 27, 2014 - Revision: 2.3
  • Microsoft COM+ 1.5
  • Microsoft COM+ 1.0
kbnosurvey kbarchive kbnofix kbprb KB305723

Give Feedback


Contact us for more help

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