diff --git a/dll.vcxproj b/dll.vcxproj
index c9e6d975..e808a124 100644
--- a/dll.vcxproj
+++ b/dll.vcxproj
@@ -133,6 +133,9 @@
Size
true
true
+ true
+ false
+ All
MachineX86
@@ -142,6 +145,7 @@
true
UseLinkTimeCodeGeneration
ntdll.lib;$(IntermediateOutputPath)mdbx_ntdll_extra.lib;kernel32.lib;advapi32.lib;%(AdditionalDependencies)
+ true
Generate fake-library mdbx_ntdll_extra.lib for $(PlatformTarget)
@@ -185,10 +189,14 @@
true
true
EnableAllWarnings
+ true
+ false
+ All
UseLinkTimeCodeGeneration
ntdll.lib;$(IntermediateOutputPath)mdbx_ntdll_extra.lib;kernel32.lib;advapi32.lib;%(AdditionalDependencies)
+ true
Generate fake-library mdbx_ntdll_extra.lib for $(PlatformTarget)
diff --git a/src/lck-windows.c b/src/lck-windows.c
index b0db378a..478c79df 100644
--- a/src/lck-windows.c
+++ b/src/lck-windows.c
@@ -27,6 +27,19 @@
static void mdbx_winnt_import(void);
#ifdef MDBX_BUILD_DLL
+/* DEBUG/CHECKED builds still require MSVC's CRT for runtime checks.
+ *
+ * Therefore we don't define dll's entry point for debug/checked builds by MSVC.
+ * In this case MSVC's will automatically use DllMainCRTStartup() from CRT
+ * library, which also automatically call DllMain() from our mdbx.dll
+ *
+ * On the other side, for RELEASE builds
+ * we explicitly define DllMain() as the entry point and don't linking with
+ * any CRT libraries (IgnoreAllDefaultLibraries = Yes). */
+#if !defined(_MSC_VER) || defined(NDEBUG)
+#pragma comment(linker, "/ENTRY:DllMain")
+#endif
+
BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID reserved)
#else
#if !MDBX_CONFIG_MANUAL_TLS_CALLBACK