首页 > 解决方案 > Windows 2012 R2 中的 .net 5.0 Core 控制台应用程序将引发错误“发生致命错误。找不到所需的库 hostfxr.dll”

问题描述

我在 Visual Studio 2019 中开发了一个 .NET 5.0 控制台应用程序,它运行良好。然后我构建项目>>将“\bin\Debug\net5.0”中的所有内容移动到Windows server 2012 R2(我们的实时服务器)内的文件夹中>>但是当我运行.exe文件时出现此错误:-

"A fatal error occurred.The required library hostfxr.dll could not be found"

这是完整的错误:-

Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\system32>cd c:\SDSPIntegration

c:\SDSPIntegration>ServiceDeskSharePointIntegration.exe
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [c:\SDSPIn
tegration\].
If this is a framework-dependent application, install the runtime in the global
location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable t
o specify the runtime location or register the runtime location in [HKLM\SOFTWAR
E\dotnet\Setup\InstalledVersions\x64\InstallLocation].

The .NET runtime can be found at:
  - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win81
-x64&apphost_version=5.0.4

请问有什么建议吗?

标签: asp.net-core.net-coredllasp.net-core-5.0

解决方案


您需要发布该程序。请参阅dotnet 发布。你可以在那里看到:

--自包含 [true|false]

与您的应用程序一起发布 .NET 运行时,因此不需要在目标计算机上安装运行时。如果指定了运行时标识符并且项目是可执行项目(不是库项目),则默认值为 true。有关详细信息,请参阅.NET 应用程序发布使用 .NET CLI 发布 .NET 应用程序


推荐阅读