Why are system's MSVC runtime DLLs used instead of ours ones sometimes?

Alervd_000 0 Reputation points
2025-03-08T10:45:07.2466667+00:00

In order to decrease our app's installer size and do not force the user to download MSVC runtime redistributable installer, we include all the MSVC runtime DLLs we need (and only them) into our installer using the following technique.

All was working fine during many years until now. Recently we've switched to use MSVC2022 and 14.42.34433.0 version of the runtime (pretty new one). Now, we're getting crash dumps from our users. Not too much (about 1 per 1000 users) with the following stack trace:

msvcp140.dll!00007ffa1d488c34() Unknown
myapp.exe!std::_Mutex_base::lock() Line 52 C++
myapp.exe!std::unique_lock::{ctor}(std::mutex &) Line 144 C++

We've analyzed all these reports and found that MSVC runtime DLLs in all these reports are loaded from C:\Windows\System32 folder, not from our app's folder. These runtime DLLs are way too older than the one we use (e.g. 14.28.29910.0 or 14.0.2415.1). And it seems they are not binary compatible with our app build.

Question: What are the possible reasons of why sometimes these system's DLLs are loaded instead of our app's provided ones?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,874 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.