当我在其他计算机上运行我的 WPF 应用程序时,它会抛出该错误。
Description: A .NET Core application failed.
Application: SamplerSLEX.exe
Path: C:\Users\admin\Downloads\TesterSLEX\TesterSLEX\SamplerSLEX.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:\Users\admin\Downloads\TesterSLEX\TesterSLEX\].
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].
Run Code Online (Sandbox Code Playgroud)
添加库运行时 3.1.0 对我有帮助。
WPF netcoreapp3.0
小智 52
除了 Ajith 的回答之外,还可以在此处在 Visual Studio 2019 中选择“部署模式:自包含”:
小智 21
我为避免依赖框架的应用程序中出现“hostfxr.dll 丢失”的解决方案是在目标计算机上安装“Hosting Bundle”。
ASP.NET Core 运行时使您能够运行现有的 Web/服务器应用程序。在 Windows 上,我们建议安装 Hosting Bundle,其中包括 .NET Core 运行时和 IIS 支持。
Aji*_*ith 17
今天我的 .Net core 3.0 应用程序出现了同样的错误。这是因为您在机器中缺少 .net 核心运行时,并且正在安装依赖于框架的应用程序。
对此的解决方案是发布具有自包含部署模式的应用程序。
使用以下命令从命令行发布
dotnet publish -c Release -r <RID> --self-contained true
Run Code Online (Sandbox Code Playgroud)
从https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#windows-rids获取 RID 详细信息
从错误消息来看,如果这是一个依赖于框架的应用程序:
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].
Run Code Online (Sandbox Code Playgroud)
请将 DOTNET_ROOT 环境设置为以下位置之一,具体取决于您安装的位置 dotnet.exe
C:\Program Files\dotnet OR C:\Program Files (x86)\dotnet
Run Code Online (Sandbox Code Playgroud)
来自“我的电脑 | 属性 | 高级 | 环境变量”。现在重新启动您的 IDE/终端,无论您使用什么。
| 归档时间: |
|
| 查看次数: |
55404 次 |
| 最近记录: |