为什么 Visual Studio 2015 不能运行 exe 文件 (ucrtbased.dll)? [英] Why Visual Studio 2015 can't run exe file (ucrtbased.dll)?

查看:89
本文介绍了为什么 Visual Studio 2015 不能运行 exe 文件 (ucrtbased.dll)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了 Visual Studio 2015 并使用一些代码创建了 Win32 项目.我编译成功了,但是我无法启动exe文件,因为我没有一些ucrtbased.dll...那么我该如何解决呢?

I have installed the Visual Studio 2015 and created Win32 project with some code. I compiled it successfully, but I can't launch exe file, because I don't have some ucrtbased.dll...So how can I solve it?

英文等效信息是:程序无法启动,因为您的计算机缺少 ucrtbased.dll.请尝试重新安装程序以解决此问题."

The English equivalent message is: "The program can't start because ucrtbased.dll is missing from your computer. Try reinstalling the program to fix this problem. "

推荐答案

此问题来自 VS 2015 静默无法复制 ucrtbased.dll (debug) 和 ucrtbase.dll (release) 在安装 Visual Studio 期间放入适当的系统文件夹.(或者您在安装过程中没有选择Common Tools for Visual C++ 2015".)这就是重新安装可能会有所帮助的原因.但是,重新安装是一种极端的措施……无需完全重新安装即可解决此问题.

This problem is from VS 2015 silently failing to copy ucrtbased.dll (debug) and ucrtbase.dll (release) into the appropriate system folders during the installation of Visual Studio. (Or you did not select "Common Tools for Visual C++ 2015" during installation.) This is why reinstalling may help. However, reinstalling is an extreme measure... this can be fixed without a complete reinstall.

首先,如果您并不真正关心底层问题,而只是想让这个one 项目快速运行,那么这里有一个快速的解决方案:只需复制 ucrtbased.dllC:Program Files (x86)Windows Kits10inx86ucrtucrtbased.dll(用于 32 位调试)到可执行文件旁边的应用程序的 debug 目录中.然后它会被找到,错误就会消失.但是,这只适用于这个one 项目.

First, if you don't really care about the underlying problem and just want to get this one project working quickly, then here is a fast solution: just copy ucrtbased.dll from C:Program Files (x86)Windows Kits10inx86ucrtucrtbased.dll (for 32bit debug) into your application's debug directory alongside the executable. Then it WILL be found and the error will go away. But, this will only work for this one project.

更持久的解决方案是将 ucrtbased.dllucrtbase.dll 放入正确的系统文件夹中.现在我们可以开始将这些文件复制到 WindowsSystem32 和 SysWOW64,它可能解决问题.然而,这并不是最好的解决方案.这首先失败是有原因的,以这种方式强制使用特定的 .dll 可能会导致重大问题.

A more permanent solution is to get ucrtbased.dll and ucrtbase.dll into the correct system folders. Now we could start copying these files into WindowsSystem32 and SysWOW64, and it might fix the problem. However, this isn't the best solution. There was a reason this failed in the first place, and forcing the use of specific .dll's this way could cause major problems.

最好的办法是打开控制面板-->程序和功能 -->Microsoft Visual Studio 2015 -->调整.然后取消选中Visual C++ -->"Visual C++ 2015 通用工具》.单击下一步,然后单击更新,几分钟后,Common Tools 应该会被卸载.然后重复,但这次安装通用工具.确保禁用防病毒,没有打开其他任务等,它应该可以工作.这是确保将这些文件准确复制到应有位置的最佳方法.

The best solution is to open up the control panel --> Programs and Features --> Microsoft Visual Studio 2015 --> Modify. Then uncheck "Visual C++ --> Common Tools for Visual C++ 2015". Click Next, then and click Update, and after a few minutes, Common Tools should be uninstalled. Then repeat, but this time install the Common Tools. Make sure anti-virus is disabled, no other tasks are open, etc. and it should work. This is the best way to ensure that these files are copied exactly where they should be.

错误代码:请注意,如果安装程序返回一个神秘的错误编号,例如 -2147023293,您可以使用任何免费的在线十进制到十六进制转换器将其转换为十六进制.对于此错误,它是 0xFFFFFFFF80070643,删除 FF 并在谷歌上搜索0x80070643",意味着0x80070643 - 安装缓存或 ISO 已损坏".

Error Codes: Note that if the installer returns a cryptic error number such as -2147023293, you can convert this to hex using any of the free online decimal-to-hex converters. For this error it is 0xFFFFFFFF80070643 which, dropping the FF's and googling for "0x80070643", means `0x80070643 - Installation cache or ISO is corrupted'.

为什么还需要 ucrtbased.dll?:任何名为crt"的 DLL是C-Run-Time"模块或库.微软解释得最好.今天有许多 CRT 的变体.它们包含所有 Microsoft 编译的可执行文件所使用的基本帮助程序代码,用于填充"程序.或帮助您的可执行文件在数量不断增加的操作系统版本和硬件上运行.如果使用 MSVC 编译器,则在编译时自动链接相关的 CRT DLL.(如果在编译时找不到 DLL,则会生成链接错误.)

Why is ucrtbased.dll even needed?: Any DLL named "crt" is a "C-Run-Time" module or library. Microsoft explains them best. There are many variants of CRT today. They contain essential helper-code used by all Microsoft compiled executables, to "shim" or help your executable operate on the ever-growing number of OS versions and hardware. If the MSVC compiler is used, the relevant CRT DLL is linked automatically at compile-time. (If the DLL cannot be found at compile-time, then a linking error is generated.)

需要 DLL 的一种方法是静态链接"DLL.它到您的项目.这意味着您实际上获取了 ucrtbased.dll 的内容,并将它包含在您的可执行文件中.您的文件大小将增加大约 ucrtbased.dll 的大小.

One way to not require the DLL, is to "statically-link" it to your project. This means that you essentially take the contents of ucrtbased.dll, and include it in your executable. Your file size will grow by approximately the size of ucrtbased.dll.

顺便说一下,如果您曾经运行过一个 MSVC 程序(通常来自另一个人,来自以前操作系统版本的旧编译程序之一,或者来自不同机器的旧程序)并且它没有启动,并给出错误消息需要Microsoft Visual C++ 20xx Redistributable"或运行时"- 那么这意味着它找不到所需的 *crt*.dll 文件.安装该特定的可再发行包(如果已知)将安装 DLL,并允许程序运行...或者至少可以克服该错误并提醒您另一个丢失的 DLL.

Incidentally, if you've ever run a MSVC program (usually from another individual, one of your old compiled programs from a previous OS version, or yours from a different machine) and it does not start, giving an error message of needing "Microsoft Visual C++ 20xx Redistributable" or "run-time" - then it means it can't find the needed *crt*.dll file. Installing that particular redistributable package (if known) will install the DLL, and allow the program to run... or at least get past that error and alert you of another missing DLL.

如果您发现自己处于这个DLL 地狱"中困境,谷歌依赖步行者";用于显示仍缺少哪些 DLL 的高级工具.专业软件通常不会发生这种情况,因为它们的(大型捆绑式)安装程序会检查是否有任何缺失的依赖库(包括 CRT)并首先安装它们.

If you find yourself in this "DLL Hell" predicament, google "dependency walker" for an advanced tool to show which DLLs are still missing. This usually doesn't happen with professional software, simply because their (large, bundled) installers check for any missing dependent libraries (including CRT) and installs them first.

这篇关于为什么 Visual Studio 2015 不能运行 exe 文件 (ucrtbased.dll)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆