ASP.NET,Visual Studio 无法构建

ASP.NET,Visual Studio 无法构建

我是 asp.net 的初学者,我想关注这个微软教程

问题是,就在一开始,就在我创建项目并尝试“不调试地构建”之后,出现一个错误,告诉我遇到了构建错误。

输出显示此消息:

1>------ Build started: Project: RazorPagesMovie, Configuration: Debug Any CPU ------
1>Failed to load the dll from [C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.11\hostpolicy.dll], HRESULT: 0x800700C1
1>An error occurred while loading required library hostpolicy.dll from [C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.11]
1>C:\Users\Owner\.nuget\packages\microsoft.aspnetcore.razor.design\2.2.0\build\netstandard2.0\Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets(79,5): error : rzc discover exited with code -2147450750.
1>Done building project "RazorPagesMovie.csproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The error list says in the description column : "rzc discover exited with code -2147450750" and in the file column : "Microsoft.AspNetCore.Razor.Design.CodeGeneration.targets"

有谁知道这是怎么回事以及如何解决它?

再说一遍,我对 Visual Studio 和 .net 不太熟悉,所以如果您好心尝试帮助我,请尽可能简化它。

答案1

就我而言,我通过在 Windows 安全中关闭“实时保护”解决了此错误:“rzc discover exited with code 1。”。我将“dotnet.exe”从“Windows Defender Antivirus”扫描中排除并/或通过“受控文件夹访问”允许它。

答案2

奇怪的是,从输出中可以看出,VS 进入了“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\2.1.11”文件夹。在我看来,这是 64 位 Program Files 文件夹,我不知道为什么 SDK 的这个目录中有一个“dotnet”文件夹。

卸载 Visual Studio 后,尝试重新安装时,我惊讶地发现 SDK 文件夹(灰色)是“Program Files”文件夹中的文件夹(而不是“Program Files(x86)”文件夹)。因此,我卸载了所有 SDK、x86 和 x64,然后重新安装了 Visual Studio,然后只安装了 x86 .Net Core 2.2 SDK,这似乎解决了我的问题。

相关内容