Unable to load library 'libSkiaSharp'.
PDFtoImage version
5.0.0
OS
Windows
OS version
Windows 11 Pro 24H2
Architecture
x64
Framework
.NET Framework
App framework
No response
Detailed bug report
Clean install of 5.0.0 with Visual Studio 2022 NuGet Package Manager.
Exception thrown when calling PDFtoImage.Conversion.ToImages( pdfData ).
DllNotFoundException: Unable to load library 'libSkiaSharp'. at SkiaSharp.SKImageInfo..ctor(Int32 width, Int32 height, SKColorType colorType, SKAlphaType alphaType) in /_/binding/SkiaSharp/SKImageInfo.cs:line 93 at PDFtoImage.Internals.PdfDocument.RenderSubset(PdfFile file, Int32 page, Single width, Single height, PdfRotation rotate, FPDF flags, Boolean renderFormFill, SKColor backgroundColor, Nullable'1 bounds, Single originalWidth, Single originalHeight, CancellationToken cancellationToken) at PDFtoImage.Internals.PdfDocument.Render(Int32 page, Nullable'1 requestedWidth, Nullable'1 requestedHeight, Single dpiX, Single dpiY, PdfRotation rotate, FPDF flags, Boolean renderFormFill, SKColor backgroundColor, Nullable'1 bounds, Boolean useTiling, Boolean withAspectRatio, Boolean dpiRelativeToBounds, CancellationToken cancellationToken) at PDFtoImage.Conversion.RenderImpl(PdfDocument pdfDocument, Int32 page, FPDF renderFlags, RenderOptions options) at PDFtoImage.Conversion.<ToImagesImpl>d__9.MoveNext() at PDFtoImage.Conversion.<ToImagesImpl>d__8.MoveNext() at PDFtoImage.Conversion.<ToImages>d__6.MoveNext()
Unable to load library 'libSkiaSharp'. at SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName) in /_ /binding/Binding.Shared/LibraryLoader.cs:line 40 at System.Lazy'1.CreateValue() at System.Lazy'1.LazyInitValue() at SkiaSharp.SkiaApi.sk_colortype_get_default_8888() in /_ /binding/SkiaSharp/SkiaApi.generated.cs:line 6052 at SkiaSharp.SKImageInfo..cctor() in /_ /binding/SkiaSharp/SKImageInfo.cs:line 48
Hi @ropst,
could you please give me an example solution to reproduce this issue? I've created a .NET Framework 4.8.1 console app and couldn't reproduce this Exception.
How does the bin folder look like? Is there a x64 folder containing libSkiaSharp.dll?
Might be related to this issue: #107
Greetings David
Hi David,
I'm using .NET Framework 4.7.2. See link below for an example project including an x64 folder without libSkiaSharp.dll.
https://sqlvadycbapn2tw6sy.blob.core.windows.net/consoleapp1/ConsoleApp1.zip?sp=r&st=2024-12-10T14:07:41Z&se=2024-12-10T22:07:41Z&spr=https&sv=2022-11-02&sr=b&sig=sHtpPqReirlVUp2nF8N%2Frf9%2FNShI9XL0nFPa6EoCF7E%3D
Regards
Thanks @ropst!
I could reproduce your issue and the libSkiaSharp.dll was missing. I believe this is caused by SkiaSharp's changed package structure. NuGet doesn't copy the dll anymore.
As a workaround you could migrate your packages.config to the new PackageReference. You can do that by right-clicking packages.config in Visual Studio and selecting "Migrate packages.config to PackageReference".
If you don't want to make that migration you could download SkiaSharp.NativeAssets.Win32, open it like a zip file and copy the file skiasharp.nativeassets.win32.2.88.9.nupkg\runtimes\win-x64\native\libSkiaSharp.dll into your output directory (under x64).
I'll open an issue in the SkiaSharp repo and try to get this fixed.
Greetings David
@ropst I've created an issue in the SkiaSharp repo (https://github.com/mono/SkiaSharp/issues/3111) and a pull request (https://github.com/mono/SkiaSharp/pull/3112) to fix it. For now you will have to use above workarounds.
@sungaila Thanks David, I will use one of the workarounds.
PDFtoImage 5.1.0 should fix this issue.