This article was previously published under Q193462
This article has been archived. It is offered "as is" and will no longer be updated.
An attempt to load a statically-linked CRT-dependent DLL when all 64 of theTLS slots are already in use fails with the following error code:
1114 -- ERROR_DLL_INIT_FAILED.
A process running on Microoft Windows 95 or Microsoft Windows NT 4.0 can only map 64 (or less) statically-linked C run-time (CRT) dependent DLLs. On Microsoft Windows 98 and Microsoft Windows Millennium Edition (Me), a process can map up to 80 such DLLs.
A statically-linked CRT-dependent DLL is one in which the CRT library is fully compiled into the DLL.
The CRT library makes use of thread-local storage (TLS). Each time astatically-linked CRT-dependent DLL is mapped into a process, the CRT isinitialized. During this initialization, a TLS slot is allocated. There areonly TLS_MINIMUM_AVAILABLE slots available to each process. This constantis guaranteed to be at least 64 on all Win32 platforms.
If you have code-control over the DLLs, dynamically link them with the CRTlibrary. This provides access to all of the CRT functions, without buildingthem directly into the executable. The DLL version of the CRT is onlyinitialized once per process.
Using the Microsoft Visual C++ compiler, you can dynamically link yourproject with the CRT library by compiling it as a Multithreaded DLL. Youcan do this by including the /MD compiler switch.
If no CRT functions are used within a DLL, you can include the linkerswitches /NODEFAULTLIB and /ENTRY:DllMain to bypass the CRT initializationcode.
This behavior is by design.
The table below lists the actual number of TLS slots available on different versions of Windows:
Windows NT 4.0
For additional information, click the article number below to view the article in the Microsoft Knowledge Base: