Microsoft KB Archive/305723

= COM application hangs when you call CoCreateInstance from DllMain =

Article ID: 305723

Article Last Modified on 12/5/2007

-

APPLIES TO


 * Microsoft COM+ 1.5
 * Microsoft COM+ 1.0

-



This article was previously published under Q305723



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



CAUSE
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.



RESOLUTION
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.



STATUS
This behavior is by design.

Keywords: kbnofix kbprb KB305723

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.