简体   繁体   English

安装 net core 后加载 hostfxr.dll 失败

[英]Failed to load the hostfxr.dll after install net core

Anyone has this problem i change Pc and tried to install net core framework but vs code return this info when i tried to write dontet --info任何人都有这个问题我改变PC并尝试安装网络核心框架但是当我尝试编写dontet --info时vs代码返回此信息

Failed to load the dll from [C:\Program 
Files\dotnet\host\fxr\2.1.0\hostfxr.dll], HRESULT: 0x80070057
The library hostfxr.dll was found, but loading it from C:\Program 
Files\dotnet\host\fxr\2.1.0\hostfxr.dll failed
- Installing .NET Core prerequisites might help resolve this problem.
 http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

Installing this update will solve the problem for Windows 7 : 安装此更新将解决Windows 7的问题:

https://www.microsoft.com/en-us/download/details.aspx?id=26767 https://www.microsoft.com/en-us/download/details.aspx?id=26767

TL;DR Since the original download is no more, here's what I found on the dell forums: TL;DR 由于原始下载已不复存在,以下是我在戴尔论坛上找到的内容:

Standalone package: Microsoft Update Catalog - KB4457144 独立软件包:Microsoft 更新目录 - KB4457144

I had the exact same error message (apart from the directories) on Win7 with a newer VC++ redist already present.我在Win7 上有完全相同的错误消息(除了目录),并且已经存在较新的 VC++ redist

The package contains the KB2533623 that we want.该软件包包含我们想要的 KB2533623。 Details of KB4457144: September 11, 2018—KB4457144 (Monthly Rollup) KB4457144 的详细信息:2018 年 9 月 11 日—KB4457144(月度汇总)

After installation and a reboot, dotnet new console goes through without an error.安装并重新启动后, dotnet new console将无错误地运行。

Dell forum source: Microsoft Windows 7 Update KB2533623 needed to install Dell Update Package (DUP)戴尔论坛来源: Microsoft Windows 7 Update KB2533623 需要安装戴尔更新包 (DUP)

I faced the same error and I checked my Web API Program.cs class and found that: .UseIISIntegration() is missing.我遇到了同样的错误,我检查了我的 Web API Program.cs类,发现: .UseIISIntegration()丢失了。 I added it and the problem solved.我添加了它,问题解决了。

public class Program
{
    public static void Main(string[] args)
    {
        CreateWebHostBuilder(args).Build().Run();
    }

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args).UseStartup<Startup>().UseIISIntegration();
}

Though it is very late but I am trying to list steps to solve this issue hope, this helps!虽然已经很晚了,但我正在尝试列出解决此问题的步骤希望,这会有所帮助! I followed the solutions provided on this link but in my case the deployment environment was the issue.我遵循了此链接上提供的解决方案,但就我而言,部署环境是问题所在。 listing down the steps I followed to fix this.列出我为解决此问题而遵循的步骤。

  1. Deploy .Net core runtime with your application if not available on target machine from https://dotnet.microsoft.com/download/dotnet-core/3.1如果目标计算机上没有https://dotnet.microsoft.com/download/dotnet-core/3.1,请使用您的应用程序部署 .Net 核心运行时
  2. set the environment variable DOTNET_ROOT设置环境变量 DOTNET_ROOT
  3. the appropriate deployment path/environment SIT/UAT (in my case) to solve this (a)"Deployment Mode: Self Contained" needs to be selected in Visual studio 2019. while publishing OR (b) dotnet publish -c Release -r --self-contained true适当的部署路径/环境 SIT/UAT(在我的情况下)来解决这个问题 (a)“部署模式:自包含”需要在 Visual Studio 2019 中选择。同时发布或 (b) dotnet publish -c Release -r - - 独立真实
  4. in case the target machine is 64 bit or 86. C:\\Program Files\\dotnet OR C:\\Program Files (x86)\\dotnet you can find the respective folder.如果目标机器是 64 位或 86 位。 C:\\Program Files\\dotnet 或 C:\\Program Files (x86)\\dotnet 您可以找到相应的文件夹。

In my case there was windows7 x64 and according to this instruction: https://docs.microsoft.com/en-us/dotnet/core/install/windows?tabs=net50就我而言,有 windows7 x64 并根据此说明: https : //docs.microsoft.com/en-us/dotnet/core/install/windows?tabs=net50

Windows 7 SP1 ESU - Microsoft Visual C++ 2015-2019 Redistributable 64-bit / 32-bit Windows 7 SP1 ESU - Microsoft Visual C++ 2015-2019 可再发行 64 位/32 位

  • KB3063858 64-bit / 32-bit KB3063858 64 位 / 32 位
  • Microsoft Root Certificate Authority 2011 (.NET Core 2.1 offline installer only) Microsoft Root Certificate Authority 2011(仅限 .NET Core 2.1 离线安装程序)

There was no KB3063858 on my machine.我的机器上没有 KB3063858。 After installation my application has started.安装后,我的应用程序已启动。

(I uset asp net 5) (我使用asp net 5)

I had the same problem, but in my case it was because I needed to clear my publish folder first.我有同样的问题,但在我的情况下,这是因为我需要先清除我的发布文件夹。 Apparently when you first publish as 32 bit and then as 64 bit, some files remain.显然,当您第一次发布为 32 位然后发布为 64 位时,会保留一些文件。 When publishing to a clean folder, the error disappeared发布到干净的文件夹时,错误消失了

This answer fixed my issue;这个答案解决了我的问题; I had built 32 bit first, then tried 64 (which was the correct build).我先构建了 32 位,然后尝试了 64(这是正确的构建)。 After I deleted the publish folder and re-publishing, the hostfxr.dll problem stopped.在我删除发布文件夹并重新发布后,hostfxr.dll 问题停止了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM