beto-rodriguez / LiveCharts2

Simple, flexible, interactive & powerful charts, maps and gauges for .Net, LiveCharts2 can now practically run everywhere Maui, Uno Platform, Blazor-wasm, WPF, WinForms, Xamarin, Avalonia, WinUI, UWP.
https://livecharts.dev
MIT License
4.38k stars 572 forks source link

libSkiasharp dll not found #1624

Closed mpiffari closed 1 month ago

mpiffari commented 1 month ago

Describe the bug After launching WinForms app, I got a not found exception and the live chart UI components get not loaded (with a red cross on it).

To Reproduce Create a project and an installer with a WinForm .NET Framework 4.8 Expected behavior

Screenshots System.DllNotFoundException: Unable to load library 'libSkiaSharp'. in SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName) in SkiaSharp.SkiaApi.<>c.<.cctor>b__1831_0() in System.Lazy1.CreateValue() --- Fine traccia dello stack da posizione precedente dove è stata generata l'eccezione --- in System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() in System.Lazy1.get_Value() in SkiaSharp.SkiaApi.sk_colortype_get_default_8888() in SkiaSharp.SKImageInfo..cctor()

Any idea on how to solve it?

beto-rodriguez commented 1 month ago

Hello

The library uses SkiaSharp to render the plot, so probably you are missing the Skia binaries in your installer, I think that you can find more help in the SkiaSharp, this issue might help you:

https://github.com/mono/SkiaSharp/issues/2758

mpiffari commented 1 month ago

@beto-rodriguez I managed to solve this issue, adding manually libskiasharp.dll and libHarfBuzzSharp.dll. I obtained this file from bin folder of winform project.

What helped me to solve the issue, was this comment: https://github.com/mono/SkiaSharp/issues/572#issuecomment-637522844

FuckAllJews commented 2 weeks ago

@mpiffari I think you have the same problem as me, and I spent more than an hour to figure out why I got this error. When I was developing a Winform application for .NET Framework 4.8 in Microsoft Visual Stadio 2022, I tried to drag FormsPlot from the toolbox to the designer interface, but failed because the error message was: "System.DllNotFoundException: Unable to load library 'libSkiaSharp'. in SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName)". Looking at the source code of SkiaSharp, I found that the above method is triggered when FromsPlot is instantiated. The Visual Stadio process directory does not contain the "libSkiaSharp.dll" file dependency. So just copy "libSkiaSharp.dll" to the working directory of Visual Stadio and restart Visual Stadio.