|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How To: Remove Dependency on _vcclrit.h
In Visual C++ .NET and Visual C++ 2003, DLLs compiled with the /clr compiler option could non-deterministically deadlock when loaded. This problem is often called the loader lock issue, and is described in detail in.
To address this problem, _vcclrit.h was provided in Visual C++ 2003 to help initialize DLLs in a manner that avoided loader lock. For Visual C++ 2005, initialization is handled in a completely different manner in order to dramatically reduce the chances of deadlock, so this header file is no longer required.
For backward compatibility, _vcclrit.h is still included, and code that uses it continues to work, but the contents of _vcclrit.h have been deprecated. This topic contains the recommended modifications required to remove dependency on this header file.
Although not an ideal solution, the deprecation warnings that result from using _vcclrit.h can be suppressed by defining _CRT_VCCLRIT_NO_DEPRECATE prior to including _vcclrit.h.
Linker Setting Changes
The following are changes that should be made to remove _vcclrit.h from projects that employed the recommended Visual C++ 2003 loader lock solution. They all involve changes to the linker settings. Seefor instructions on changing these settings through Visual Studio.
Remove the /NOENTRY linker switch. Using _vcclrit.h required that theswitch be provided to the linker. This is no longer necessary.
Do not explicitly input MSVCRT.LIB to the linker. Because the /NOENTRY switch was required, it was necessary to explicitly link to the CRT library file MSVCRT.LIB. With /NOENTRY removed, this library is linked in by default under /clr compilation.
Remove of NOCHKCLR.OBJ from linker input. This file is no longer required.
Remove Forced Symbol References. Previously, it was necessary to force the following symbols with the /INCLUDE switch: __DllMainCRTStartup@12, __crt_dll_initialize, and __crt_dll_terminate. None of these symbols are necessary in Visual C++ 2005, so they can safely be removed.
Other than removing #include <_vcclrit.h> from your code, some additional changes may be necessary depending on the nature of your code. At the minimum, __crt_dll_initialize and __crt_dll_terminate will simply no longer be invoked, and can therefore be removed.