Dot-Net-Core

發生致命錯誤。找不到所需的庫 hostfxr.dll

  • December 11, 2019

當我在其他電腦上執行我的 WPF 應用程序時,它會拋出這個錯誤:

Description: A .NET Core application failed.
Application: program.exe
Path: C:\fakepath\program.exe
Message: 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:\fakepath\].
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 to specify the runtime location or 
register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x64\InstallLocation].

添加庫執行時 3.1.0 它對我有幫助。

除了 Ajith 的回答之外,還可以在此處的 Visual Studio 2019 中選擇“部署模式:自包含”:

Visual Studio 中的圖形使用者界面

引用自:https://stackoverflow.com/questions/59284895