【发布时间】:2020-07-17 22:34:25
【问题描述】:
在 Linux 上使用带有 .NET Core 2.2 的 SkiaSharp 1.68.0 并在尝试在 jpeg-memory-stream 上使用 Decode 时出现此错误(相同的代码适用于 Windows):
System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory
at SkiaSharp.SkiaApi.sk_managedstream_set_delegates(IntPtr pRead, IntPtr pPeek, IntPtr pIsAtEnd, IntPtr pHasPosition, IntPtr pHasLength, IntPtr pRewind, IntPtr pGetPosition, IntPtr pSeek, IntPtr pMove, IntPtr pGetLength, IntPtr pCreateNew, IntPtr pDestroy)
at SkiaSharp.SKAbstractManagedStream..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKAbstractManagedStream..ctor(Boolean owns)
at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream, Boolean owns)
at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream)
at SkiaSharp.SKCodec.WrapManagedStream(Stream stream)
at SkiaSharp.SKCodec.Create(Stream stream, SKCodecResult& result)
at SkiaSharp.SKCodec.Create(Stream stream)
at SkiaSharp.SKBitmap.Decode(Stream stream)
最里面的错误消息似乎是“没有这样的文件或目录”,这很奇怪,因为我正在解码内存流。这适用于 Windows,在我升级到 .NET Core 2.2 和最新的 SkiaSharp 之前,它也适用于 Linux。
我已尝试按照错误消息中的建议设置 LD_DEBUG 环境变量,但这并没有起到多大作用。不确定将其设置为什么。尝试了“全部”,但没有产生任何更详细的日志。
找到了一个thread,它建议安装 SkiaSharp.NativeAssets.Linux 作为解决方案,但不幸的是这并没有帮助。构建/发布时是否需要以 Linux-x64 运行时为目标?尝试了不同的组合,但没有发现任何差异。 (我在 Linux 上的 Docker 文件中使用 dotnet cli 通过 ssh 和 putty 构建。几乎是由 VS:latest 生成的默认 Docker 文件)
另一个建议是手动安装 libSkiaSharp.so 和 apt-get install libfontconfig1,但遗憾的是 apt-get 在 Synology DSM 上不可用。
【问题讨论】: