Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DllNotFoundException using SkiaSharp 1.68 on Linux

Using SkiaSharp 1.68.0 with .NET Core 2.2 on Linux and get this error when trying to use Decode on a jpeg-memory-stream (same code works on 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) 

The inner-most error message seem to be "No such file or directory" which is strange since I'm decoding a memory-stream. This works on Windows and it have worked on Linux before I upgraded to .NET Core 2.2 and latest SkiaSharp.

I have tried setting the LD_DEBUG env variable as suggested in the error message but that didn't do much. Not sure what to set it to really. Tried 'all' but that didn't result in any more detailed log.

Found a thread that suggests installing SkiaSharp.NativeAssets.Linux as a solution, but unfortunately that didn't help. Do I need to target Linux-x64 runtime when building/publishing? Have tried different combinations but couldn't detect any difference. (I'm building with dotnet cli in a Docker-file on Linux over ssh with putty. Pretty much default Docker-file as generated by VS:latest)

Another suggestion was to install libSkiaSharp.so manually and also apt-get install libfontconfig1, but unfortunately apt-get is not available on Synology DSM.

like image 628
Andreas Zita Avatar asked Dec 09 '18 13:12

Andreas Zita


People also ask

What are the common exceptions in skiasharp?

{System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedWStream' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'libSkiaSharp': The specified module or one of its dependencies could not be found.

Is there a skiasharp DLL for API?

I added a package ref for SkiaSharp to the Api project also, just in case. Neither of the projects has SkiaSharp.dll in the output folders. Sorry, something went wrong. Sorry, something went wrong.

Does skiasharp work on Synology?

FYI: There's a new version of SkiaSharp without any dependencies that works great on Synology as well, without having to install any font-libs (works great with resizing images but without the text-rendering-support) – Andreas Zita Jun 14 '20 at 20:16


1 Answers

Installing Linux dependency NuGet Package will solve this issue SkiaSharp.NativeAssets.Linux.NoDependencies https://www.nuget.org/packages/SkiaSharp.NativeAssets.Linux.NoDependencies

like image 97
vinayak hegde Avatar answered Sep 28 '22 04:09

vinayak hegde