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

[BUG] WPF app crashes with SkiaSharp 3.116.1: DllNotFoundException: Unable to load library 'libSkiaSharp'. #3107

Open
1 task done
niza93 opened this issue Dec 6, 2024 · 2 comments
Labels

Comments

@niza93
Copy link
Contributor

niza93 commented Dec 6, 2024

Description

I create new WPF application with .NET Framework 4.8.1, next I install SkiaSharp.Views.WPF 3.116.1.
When I run this app I get the exception: DllNotFoundException: Unable to load library 'libSkiaSharp'.
You can check it, I attach sample repro project.
SkiaSharp3.x_Issue.zip

Also I can't use SKGLElement, because I have following error: Не удалось загрузить файл или сборку "GLWpfControl, Version=3.3.0.0, Culture=neutral, PublicKeyToken=null" либо одну из их зависимостей. Требуется сборка со строгим именем. (Исключение из HRESULT: 0x80131044)

Code

<Window x:Class="SkiaSharp3.x_Issue.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:skia="clr-namespace:SkiaSharp.Views.WPF;assembly=SkiaSharp.Views.WPF"
        xmlns:local="clr-namespace:SkiaSharp3.x_Issue"
        mc:Ignorable="d"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
    <skia:SKElement/>
  </Grid>
</Window>

Expected Behavior

App builds and run without any exceptions.

Actual Behavior

App doesn't build with SKGLElement and crashes with SKElement

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

2.88.9 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows 11 24H2

Devices

Windows desktop

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@niza93
Copy link
Contributor Author

niza93 commented Dec 6, 2024

Modified SkiaHelper from #572 (comment) solves this issue, but only for SKElement, SKGLElement still doesn't load

public static class SkiaHelper
{
  [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  private static extern IntPtr LoadLibrary(string libname);

  public static void LoadNativeLibrary()
  {
    var libSkiaSharpPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
    libSkiaSharpPath = Path.Combine(libSkiaSharpPath, "libSkiaSharp.dll");

    LoadLibrary(libSkiaSharpPath);
  }
}

@jjzhang12
Copy link
Contributor

jjzhang12 commented Dec 14, 2024

We got same error in Skiasharp 3.116.1 in .net 8 blazor when we compiled with .net sdk 8.0.11. It's fine though when compiled with .net sdk 8.0.10.

For comparison, the Skiasharp 2.88.8 is working fine for both .net sdk 8.0.10 and 8.0.11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: New
Development

No branches or pull requests

2 participants