运行 ARM64 上的 .NET 5.0 应用程序 CPU

Run .NET 5.0 application on ARM64 CPU

我正在将一个控制台应用程序从我的 PC 转移到 RPI4。我在那里安装了 Ubuntu 21.04 OS。 该应用程序采用 .NET 5.0 架构编写。我已经使用以下配置发布了它

注意:我也尝试过独立模式,但它产生了同样的错误。

我遇到的第一个问题是我需要为 .NET5 安装运行时和 SDK,所以我做到了。这是我安装的: 这是环境:

然后我意识到 VS 只提供 arm32 运行时。我在互联网上找到了这个指南:https://forum.armbian.com/topic/4764-running-32-bit-applications-on-aarch64/

现在我遇到了以下错误。

Unhandled exception. System.Net.Http.HttpRequestException: Error while copying content to a stream. ---> System.IO.Compression.ZLibException: The underlying compression routine could not be loaded correctly. ---> System.DllNotFoundException: Unable to load shared library 'libSystem.IO.Compression.Native' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSystem.IO.Compression.Native: cannot open shared object file: No such file or directory at Interop.zlib.InflateInit2_(ZStream& stream, Int32 windowBits) at System.IO.Compression.ZLibNative.ZLibStreamHandle.InflateInit2_(Int32 windowBits) at System.IO.Compression.Inflater.InflateInit(Int32 windowBits)

这似乎与它为 arm32 部署而 rpi4 有 arm64 的事实有关CPU,但我找不到任何解决方法。

万一有人发现这个问题,原来是 VS 无法在 64 位 ARM 上部署应用程序 linux。您需要在 RPI 上安装 32 位版本的 linux 才能使其正常工作。不是最佳解决方案,但效果很好。