visual-studio 为什么我在构建安装项目时收到“验证时发生错误。HRESULT = '80004005'”?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/986224/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:38:41  来源:igfitidea点击:

Why do I get "An error occurred while validating. HRESULT = '80004005'" when building a setup project?

visual-studiosetup-project

提问by Martin Delille

Why do I get the following error when building a setup project?

为什么在构建安装项目时会出现以下错误?

An error occurred while validating. HRESULT = '80004005'

验证时出错。HRESULT = '80004005'

采纳答案by Martin Delille

This error is related to a dependency error. I removed all references to my primary output project and added them again. It now compiles OK!

此错误与依赖项错误有关。我删除了对我的主要输出项目的所有引用,然后再次添加了它们。现在可以编译了!

回答by thewpfguy

One project in solution had ToolsVersion="4.0"(in .csproj file), changed it to ToolsVersion="3.5"and setup project builds fine.

解决方案中的一个项目ToolsVersion="4.0"(在 .csproj 文件中)将其更改为ToolsVersion="3.5"并设置项目构建正常。

回答by Justin Pihony

Both of the reasons I found are already in other answers, but they are in separate answers and not fully explained. So, hopefully this will combine the possibilities and give good means of debugging each. :)

我发现的两个原因都已经在其他答案中了,但是它们在单独的答案中并且没有得到充分解释。因此,希望这将结合各种可能性并提供调试每个可能性的好方法。:)

Common Reason

常见原因

My problem was not a dependency error. However, that does seem to be the common reason. So, basically, you need to check your MSIfile and make sure that all dependencies are still valid. Probably the best blog response on how you can easily resolve this if it is a dependency issue is An error occurred while validating. HRESULT = '80004005'.

我的问题不是依赖错误。然而,这似乎是普遍的原因。因此,基本上,您需要检查MSI文件并确保所有依赖项仍然有效。如果这是一个依赖问题,关于如何轻松解决此问题的最佳博客回复可能是验证时发生错误。HRESULT = '80004005'

Extract from blog:

摘自博客

Follow steps below to troubleshoot.

  • If you have multiple project outputs in your solution, identify the project that is giving the problem. You can do that by removing one project at a time from the Setup Project(S) until error goes away.
  • Once project is identified, identify the reference that could be giving the problem.

    • Check if the project(A) is referencing to a project that has been removed from solution. - Remove such references if any.
    • Check if the Project(A) is referencing to a project that was moved to a diffenrent physical location after it was added as a reference. - Remove and add such references.
  • Rebuild setup project after fixing the reference accordingly to see if error goes away.

请按照以下步骤进行故障排除。

  • 如果您的解决方案中有多个项目输出,请确定出现问题的项目。您可以通过一次从安装项目中删除一个项目来实现这一点,直到错误消失为止。
  • 一旦确定了项目,请确定可能导致问题的参考。

    • 检查项目(A)是否引用了已从解决方案中删除的项目。- 删除此类引用(如果有)。
    • 检查项目(A) 是否引用了在添加为引用后移动到不同物理位置的项目。- 删除并添加此类引用。
  • 相应地修复参考后重建安装项目以查看错误是否消失。

Alternative Reason

其他原因

My problem had to do with Visual Studio versioning, however. So, if your dependencies are valid and you still are getting this problem, then you resolve this if it is a problem with VS2010 .

但是,我的问题与 Visual Studio 版本控制有关。因此,如果您的依赖项有效并且您仍然遇到此问题,那么如果它是 VS2010 的问题,那么您可以解决此问题.

Basically, if you run MSBuildand see this warning:

基本上,如果您运行MSBuild并看到此警告:

Project file contains ToolsVersion="4.0", which is not supported by this version of MSBuild. Treating the project as if it had ToolsVersion="3.5"

项目文件包含 ToolsVersion="4.0",此版本的 MSBuild 不支持。将项目视为具有 ToolsVersion="3.5"

Then the problem is Visual Studio versioning. This means that one project was opened or created in Visual Studio 2010 and then saved or added to an existing 3.5 solution. I simply searched all files in my project for ToolsVersion="4.0"and found the offending .csprojfile, opened it in a text editor and manually changed the 4.0to a 3.5.

那么问题是 Visual Studio 版本控制。这意味着在 Visual Studio 2010 中打开或创建了一个项目,然后将其保存或添加到现有 3.5 解决方案中。我简单地搜索所有的文件在我的项目ToolsVersion="4.0",发现有问题的.csproj文件,在文本编辑器中打开它,并手动更改4.03.5

回答by Joseph Anderson

I ran up against this issue today. The solution in my case? Restart Visual Studio 2008.

我今天遇到了这个问题。在我的情况下的解决方案?重新启动 Visual Studio 2008。

回答by riper

In my case my solution (VS2008) had a project that was also referenced from another solution (VS2010). In the VS2010 solution I had upgraded the project to .NET 4.0. When I later realized the project was also used in another solution I downgraded it to .NET 3.5. For some reason everything seemed to be changed correctly in the csproj file except one place which is mentioned here: Error in setup project HRESULT = '80004005'

就我而言,我的解决方案 (VS2008) 有一个项目,该项目也从另一个解决方案 (VS2010) 中引用。在 VS2010 解决方案中,我已将项目升级到 .NET 4.0。当我后来意识到该项目也用于另一个解决方案时,我将其降级为 .NET 3.5。出于某种原因,csproj 文件中的所有内容似乎都已正确更改,除了此处提到的一个地方:安装项目 HRESULT = '80004005' 中的错误

I know this is already solved somewhere else but I wanted to shed some light on this from another problem angle.

我知道这已经在其他地方解决了,但我想从另一个问题的角度对此有所了解。

回答by David Beckman

While simply removing and re-adding the project dependencies will work in many cases, it is important to note that:

虽然简单地删除和重新添加项目依赖项在许多情况下都有效,但重要的是要注意:

The error message "An error occurred while validating. HRESULT=80004005." usually happens when project is referenced to the other project which is not added into the currect [sic] solution. Setup project only supports dependency projects within same solution.1

错误消息“验证时出错。HRESULT=80004005。” 通常发生在项目被引用到未添加到当前 [sic] 解决方案中的另一个项目时。安装项目仅支持同一解决方案中的依赖项目。1

回答by Vidas Vasiliauskas

I have spent enormous time on this one myself, though none of the above worked. But I have found another solution with a registry hack, you need to add a new DWORD (EnableOutOfProcBuild) value of (0) to HKCU\SOFTWARE\Microsoft\VisualStudio\14.0_Config\MSBuild\EnableOutOfProcBuild

我自己花了很多时间在这个上面,尽管以上都没有奏效。但是我找到了另一种注册表破解的解决方案,您需要将 ( EnableOutOfProcBuild)的新 DWORD ( ) 值添加0HKCU\SOFTWARE\Microsoft\VisualStudio\14.0_Config\MSBuild\EnableOutOfProcBuild

Note: this is for Visual Studio 2015

注意:这是针对 Visual Studio 2015

回答by Jon

In my case I had installed Visual Studio 2010 alongside Visual Studio 2008. My setup project, when opened in Visual Studio 2008 gave the same error, but was OK in Visual Studio 2010.

就我而言,我安装了 Visual Studio 2010 和 Visual Studio 2008。我的安装项目在 Visual Studio 2008 中打开时出现了同样的错误,但在 Visual Studio 2010 中没有问题。

If copied to another machine that did not have Visual Studio 2010, but did have Visual Studio 2008, then it would compile.

如果复制到另一台没有 Visual Studio 2010 但有 Visual Studio 2008 的机器,那么它会编译。

回答by tablaplanet

I read this answer from another post on Stack Overflow, and it has worked for me.

我从 Stack Overflow 上的另一篇文章中阅读了这个答案,它对我有用。

Open your setup project file (.vdproj) in Notepad(or any other text editor). Delete these lines at a beginning of the .vdproj file:

记事本(或任何其他文本编辑器)中打开您的安装项目文件 (.vdproj )。删除 .vdproj 文件开头的这些行:

"SccProjectName" = "8:"
"SccLocalPath" = "8:"
"SccAuxPath" = "8:"
"SccProvider" = "8:"

Build again - the error is gone. That error didn't stop me from deploying, building, debugging (or anyting) my project; it just annoyed me. And it came on even if I set all projects to be build in a current configuration and the setup project not to.

再次构建 - 错误消失了。这个错误并没有阻止我部署、构建、调试(或任何)我的项目;它只是让我很恼火。即使我将所有项目设置为在当前配置中构建而安装项目不这样做,它也会出现。

回答by Dan B

I know this is kinda old news, but my particular issue and solution are not specifically stated here (as far as I can tell - if I missed it, I apologize).

我知道这有点陈旧,但我的特定问题和解决方案并未在此处具体说明(据我所知 - 如果我错过了,我深表歉意)。

I had same problem. It would not compile my project, but had no errors. All I could see was "Build Failed". I opened up the "Output" file (Click View--> Output on menu), and it told me exactly which reference (in my case a .dll) was causing the problem.

我有同样的问题。它不会编译我的项目,但没有错误。我只能看到“构建失败”。我打开了“输出”文件(单击菜单上的“查看”-->“输出”),它准确地告诉我是哪个引用(在我的情况下是 .dll)导致了问题。

I deleted and recreated the reference and it changed the reference name from Microsoft.Office.Core (which was appearently only a 32 bit version) to "OFFICE". Then everything worked great. -- Make sure to make a note of the path to the file you are referencing in the properties window... My new path was exactly the same, but the reference name changed anyway.... still scratching my head on that one...

我删除并重新创建了引用,并将引用名称从 Microsoft.Office.Core(似乎只有 32 位版本)更改为“OFFICE”。然后一切都很好。-- 请务必记下您在属性窗口中引用的文件的路径...我的新路径完全相同,但无论如何引用名称已更改.... 仍然在抓挠我的头。 ..

So the moral of the story is... When you get no errors and your build fails, check the "Output" tab and it might help.

所以这个故事的寓意是......当你没有错误并且你的构建失败时,检查“输出”选项卡,它可能会有所帮助。