windows 2012 R2 中的 .net 5.0 核心控制台应用程序将引发错误 "A fatal error occurred.The required library hostfxr.dll could not be found"
.net 5.0 Core console application inside windows 2012 R2 will raise error "A fatal error occurred.The required library hostfxr.dll could not be found"
我在 Visual Studio 2019 年开发了一个 .NET 5.0 控制台应用程序,它运行良好。然后我构建项目>>将“\bin\Debug\net5.0”中的所有内容移动到Windows服务器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 publish。你可以在那里看到:
--self-contained [true|false]
Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. Default is true if a runtime identifier is specified and the project is an executable project (not a library project). For more information, see .NET application publishing and Publish .NET apps with the .NET CLI.
我在 Visual Studio 2019 年开发了一个 .NET 5.0 控制台应用程序,它运行良好。然后我构建项目>>将“\bin\Debug\net5.0”中的所有内容移动到Windows服务器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 publish。你可以在那里看到:
--self-contained [true|false]
Publishes the .NET runtime with your application so the runtime doesn't need to be installed on the target machine. Default is true if a runtime identifier is specified and the project is an executable project (not a library project). For more information, see .NET application publishing and Publish .NET apps with the .NET CLI.