Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load library 'libSkiaSharp'. #108

Open
ropst opened this issue Dec 10, 2024 · 5 comments
Open

Unable to load library 'libSkiaSharp'. #108

ropst opened this issue Dec 10, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@ropst
Copy link

ropst commented Dec 10, 2024

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.d__9.MoveNext()
at PDFtoImage.Conversion.d__8.MoveNext()
at PDFtoImage.Conversion.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

@ropst ropst added the bug Something isn't working label Dec 10, 2024
@sungaila
Copy link
Owner

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

@ropst
Copy link
Author

ropst commented Dec 10, 2024

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

@sungaila
Copy link
Owner

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

@sungaila
Copy link
Owner

sungaila commented Dec 10, 2024

@ropst I've created an issue in the SkiaSharp repo (mono/SkiaSharp#3111) and a pull request (mono/SkiaSharp#3112) to fix it. For now you will have to use above workarounds.

@ropst
Copy link
Author

ropst commented Dec 10, 2024

@sungaila Thanks David, I will use one of the workarounds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants