ZXing.Net.Bindings.SkiaSharp Linux环境报错解决
ZXing.Net.Bindings.SkiaSharp Linux环境报错解决
报错代码
//docker netcore3.1
var stream = HttpUitl.GeMemoryStream(url);
using (var skiaImage = SkiaSharp.SKBitmap.Decode(stream))
{
var skiaReader = new ZXing.SkiaSharp.BarcodeReader();
var skiaResult = skiaReader.Decode(skiaImage);
content = skiaResult?.Text;
}
Linux环境异常
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_procs(SKManagedStreamDelegates procs)
at SkiaSharp.SKAbstractManagedStream..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKAbstractManagedStream..ctor(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)
解决
参考:https://www.cnblogs.com/jopny/p/9394644.html (解决思路)
最终在 SkiaSharp github上找到解决方案
SkiaSharp.NativeAssets.Linux.NoDependencies (和SkiaSharp对应)
以此纪念陪伴我十年的狗狗