Calls to an OLE Object Should Not Be Done from DllMain (138812)
The information in this article applies to:
- Microsoft OLE Libraries, when used with:
- the operating system: Microsoft Windows NT 3.51
- the operating system: Microsoft Windows NT 4.0
- the operating system: Microsoft Windows 95
- the operating system: Microsoft Windows 2000
This article was previously published under Q138812 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.
Modification Type: | Major | Last Reviewed: | 12/3/2003 |
---|
Keywords: | kbprogramming KB138812 |
---|
|