Skip to content

[BUG] .Net Framework 4.7.2 ClickOnce package - Unable to load library 'libSkiaSharp' #3423

@ajohnstone-ks

Description

@ajohnstone-ks

Description

SkiaSharp Nuget version: 3.119.1

We're adding SkiaSharp to our .net winforms app (framework 4.7.2) for the first time, and we have a problem where the ClickOnce version of the app throws the following exception.

System.TypeInitializationException: The type initializer for 'SkiaSharp.SKData' threw an exception. ---> System.DllNotFoundException: Unable to load library 'libSkiaSharp'.
   at SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at SkiaSharp.SkiaApi.sk_data_new_empty()
   at SkiaSharp.SKData..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKData.Create(IntPtr address, Int32 length)
   at SkiaSharp.SKBitmap.Decode(ReadOnlySpan`1 buffer)
   at SkiaSharp.SKBitmap.Decode(Byte[] buffer)

Our MSIX version of the app does not however, and I think its because libSkiaSharp.dylib is not being included in the ClickOnce publish, even though I have it configured to (the Application Files dialog says its not referenced). That file IS included in the MSIX package however.

Code

var image = SKBitmap.Decode(imageData ?? throw new ArgumentNullException(nameof(imageData)))

In a WinForms app, then published with ClickOnce.

Expected Behavior

I expect the image to be decoded.

Actual Behavior

An exception: System.DllNotFoundException: Unable to load library 'libSkiaSharp'

Version of SkiaSharp

3.116.0 (Current)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

  • Windows 11
  • Windows 10

Devices

  • Dell workstations

Relevant Screenshots

No response

Relevant Log Output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions