c++ - Visual Studio 2015 C++ 应用程序需要客户端客户端上的 api-ms-win-crt-runtime-l1-1-0.dll

标签 c++ windows visual-studio dll

我使用 Visual Studio 2015 社区版构建了一个应用程序。当我的一些用户尝试运行它时,他们收到以下错误:

The program can't start because api-ms-win-crt-runtime-l1-1-0.dll is missing from your computer. Try reinstalling the program to fix this problem.

很明显,这可以通过安装 Update for Universal C Runtime in Windows 来解决。 (KB2999226)。我可以在安装脚本期间检查修补程序,但我发现的所有方法都是 too slow or unreliable .

如何防止此错误发生?我可以更改我的解决方案,以便我不需要这种依赖关系吗?我是否链接了我可以删除的东西?我可以将修补程序与我的应用程序一起重新分发吗?

编辑:在项目属性中,“目标平台版本”为 8.1,“平台工具集”为“Visual Studio 2015 (v140)”,如果有帮助的话。

编辑 2:Microsoft now allows (but doesn't recommend) local mode installation of the UCRT 以来,我已尝试将所有通用 C 运行时库 DLL 复制到应用程序目录。 . C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x64api-ms-win-crt-runtime-l1-1 共有 41 个文件-0.dll 就是其中之一。但是,现在运行应用程序会导致此错误:

The application was unable to start correctly (0xc0000142). Click OK to close the application.

我已尝试使用 MSVS 2015 调试应用程序,但无济于事。我在 Dependency Walker 中打开了可执行文件,似乎我缺少 this answer, which says that Dependency Walker is old and this is a red herring. 中列出的类似 DLL。

我尝试通过进程监视器 (procmon) 运行应用程序,但没有任何异常。应用程序只需调用 WerFault.exe 上的“Process Create”,然后调用“Thread Exit”。

编辑 3: 我启用了 loader snaps在可执行文件上,并在从 cdb 运行它时得到这个,如果有帮助的话:

...
00c0:1200 @ 02106250 - LdrpFindOrMapDependency - RETURN: Status: 0x00000000
00c0:1200 @ 02106250 - LdrpFindOrMapDependency - ENTER: DLL name: api-ms-win-core-sysinfo-l1-2-1.dll.
00c0:1200 @ 02106250 - LdrpFindOrMapDependency - INFO: DLL name api-ms-win-core-sysinfo-l1-2-1.dll was redirected to C:\WINDOWS\SYSTEM32\kernelbase.dll by SxS.
00c0:1200 @ 02106250 - LdrpFindOrMapDll - ENTER: DLL name: C:\WINDOWS\SYSTEM32\kernelbase.dll
00c0:1200 @ 02106250 - LdrpResolveDllName - ENTER: DLL name: C:\WINDOWS\SYSTEM32\kernelbase.dll
00c0:1200 @ 02106250 - LdrpResolveDllName - RETURN: Status: 0x00000000
00c0:1200 @ 02106250 - LdrpFindOrMapDll - RETURN: Status: 0x00000000
00c0:1200 @ 02106250 - LdrpFindOrMapDependency - RETURN: Status: 0x00000000
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlSetLastWin32Error" by name
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlLeaveCriticalSection" by name
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlEnterCriticalSection" by name
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlInitializeCriticalSection" by name
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlDeleteCriticalSection" by name
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "RtlQueryPerformanceCounter" by name
00c0:1200 @ 02106250 - LdrpGetProcedureAddress - INFO: Locating procedure "LdrResolveDelayLoadedAPI" by name
00c0:1200 @ 02106250 - LdrpMergeNodes - INFO: Merging a cycle rooted at USER32.dll.
00c0:1200 @ 02106250 - LdrpMergeNodes - INFO: Adding cyclic module GDI32.dll.
(c0.1200): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for ntdll.dll -
ntdll!LdrInitShimEngineDynamic+0x330:
00007ffc`d68732e8 cc              int     3
0:000>

最佳答案

您应该与 CRT 进行静态链接。对于消费者应用程序,有很多情况会导致特定的 DLL 丢失或其配置失败。我是一个非常流行的 Windows 应用程序(每天安装数千次)的安装程序技术主管,你不会相信错误配置的 Windows 机器有多么普遍。在底部我会给出一个简短的列表。

通用 CRT 是一个好主意,但相对较新,而且需要一段时间(可能很长一段时间),直到它被破坏会阻止您客户的 PC 启动。这应该是阈值:如果您的客户在没有 DLL X 的情况下无法登录,那么可以依赖它。

常见的奇怪状态:

  • MSI 安装程序正在进行中:Windows 不知何故认为存在 正在安装
  • COM 数据库不一致:HKCU 部分 注册表是一个粗糙的地方
  • 其中缺少 MSVC crts 或预发布版本
  • Windows 的预发布版本:我们猜想 预发布的 Windows 更容易被盗版。
  • 仍在 sysprep 中:OEM 忘记密封机器配置了。
  • 字体损坏:如果使用 DirectWrite 会特别痛苦
  • 超频:文件系统缓冲区中的最终位翻转等于损坏的文件。

关于c++ - Visual Studio 2015 C++ 应用程序需要客户端客户端上的 api-ms-win-crt-runtime-l1-1-0.dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35072133/

相关文章:

c++ - 为什么这行得通? C中的字符指针

c++ - BST-插入说明

windows - assembly 计数程序

c# - 命名空间和物理项目结构的重构工具

c# - 在文件夹中创建类时更改默认命名空间 (Visual Studio)

xml - 有没有办法将一个代码片段嵌入另一个代码片段?

c++ - 在 qDebug() 中避免换行

c++ - 与 QML 共享 C++ 对象实例

windows - 为什么无法从具有 PAGE_GUARD 保护的 block 中读取数据?

c - 如何在 C 语言中通过串行端口发送 0xff 字节?