asp.net-core - 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
请问有什么建议吗?
解决方案
您需要发布该程序。请参阅dotnet 发布。你可以在那里看到:
--自包含 [true|false]
与您的应用程序一起发布 .NET 运行时,因此不需要在目标计算机上安装运行时。如果指定了运行时标识符并且项目是可执行项目(不是库项目),则默认值为 true。有关详细信息,请参阅.NET 应用程序发布和使用 .NET CLI 发布 .NET 应用程序。
推荐阅读
- asp.net-mvc - 在没有 AspNetCore Web 应用程序的情况下使用存储在 Razor 类库 3.0 (RCL) 中的 Razor 模板
- c# - .net core 3 equivalnet 配置用于添加 xml 序列化
- java - 在远程调试中暂停 Spring Boot Java 应用程序时,ECS 代理停止并重新启动 Docker 容器
- c# - 当我在 MVC 视图中尝试第二页时,ToPagedList 没有给出值
- git - 主分支更改后合并开发分支(已提交)
- javascript - 显示另一个div后如何显示div
- java - Spring Boot 中的 ObjectMapper 可以读取字符串,但在解析标头时不起作用
- ios - 证书和配置配置文件混淆 Xcode
- uwp - 通用应用程序中的动态菜单
- android - 在 Kotlin 中成功完成另一个函数后,如何让一个函数执行?