SkiaSharp errors on with .NET Core 5

Hello

I have a .NET Core 5 app running in a Pivotal Cloud Foundry container on a Linux (Ubuntu Bionic 18.04 LTS) buildpack, using

  • Aspose.Words 21.8.0,
  • Aspose.PDF 21.8.0
  • SkiaSharp.NativeAssets.Linux.NoDependencies 2.88.0-preview.127

and I am seeing the error below from Aspose.Words. I’ve tried different combinations of SkiaSharp.NativeAssets.Linux.NoDependencies, SkiaSharp.NativeAssets.Linux, etc versions, but haven’t been able to find a combination that works. (The SkiaSharp package currently referenced looks to be a match with the 88.0 version from the error message.)

Is there a different nuget package we should be using to avoid this issue?

Thanks!

System.TypeInitializationException: The type initializer for '​ ' threw an exception.
---> System.TypeInitializationException: The type initializer for 'SkiaSharp.SKObject' threw an exception.
---> System.InvalidOperationException: The version of the native libSkiaSharp library is incompatible with this version of SkiaSharp. Supported versions of the native libSkiaSharp library are in the range [88.0, 89.0).
at SkiaSharp.SkiaSharpVersion.CheckNativeLibraryCompatible(Version minSupported, Version current, Boolean throwIfIncompatible)
at SkiaSharp.SkiaSharpVersion.CheckNativeLibraryCompatible(Boolean throwIfIncompatible)
at SkiaSharp.SKObject..cctor()
--- End of inner exception stack trace ---
at SkiaSharp.SKObject..ctor(IntPtr handle, Boolean owns)
at SkiaSharp.SKBitmap..ctor(IntPtr handle, Boolean owns)
at SkiaSharp.SKBitmap..ctor()
at SkiaSharp.SKBitmap..ctor(SKImageInfo info, Int32 rowBytes)
at SkiaSharp.SKBitmap..ctor(SKImageInfo info)
at SkiaSharp.SKBitmap..ctor(Int32 width, Int32 height, SKColorType colorType, SKAlphaType alphaType)
at SkiaSharp.SKBitmap..ctor(Int32 width, Int32 height, Boolean isOpaque)
at ​ ..cctor()
...
at Aspose.Words.Document.UpdatePageLayout()
...
at Aspose.Words.Range.UpdateFields()
at Aspose.Words.Document.UpdateFields()

@mark.foreman I tested the scenario in Docker with Ubuntu and the versions of Aspose.Words and SkiaSharp you have specified and have not found any issues.
Please make sure libSkiaSharp.so is properly deployed.

Thank you Alexey. Turns out there was an issue with Nuget on my machine that was causing the incorrect library file to be deployed - clearing the Nuget cache seems to fixed that issue.

However, there were new errors when using Aspose.PDF 21.8.0, Aspose.Words 21.9.0 and SkiaSharp.NativeAssets.Linux.NoDependencies 2.88.0-preview.127:

2021-09-06T20:36:45.670+10:00 [APP/PROC/WEB/0] [ERR] Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'buffer')
2021-09-06T20:36:45.671+10:00 [APP/PROC/WEB/0] [ERR] at SkiaSharp.SKManagedStream.OnReadManagedStream(IntPtr buffer, IntPtr size)
2021-09-06T20:36:45.671+10:00 [APP/PROC/WEB/0] [ERR] at SkiaSharp.SKManagedStream.OnRead(IntPtr buffer, IntPtr size)
2021-09-06T20:36:45.671+10:00 [APP/PROC/WEB/0] [ERR] at SkiaSharp.SKAbstractManagedStream.ReadInternal(IntPtr s, Void* context, Void* buffer, IntPtr size)

I found [BUG] 2.84.0-preview.4: SKCodec.Create - Value cannot be null. Parameter name: buffer · Issue #1551 · mono/SkiaSharp · GitHub which suggested downgrading to SkiaSharp.NativeAssets.Linux.NoDependencies 2.80.2, which still had the same error, but downgrading Aspose.Words to Aspose.Words 21.8.0 in conjunction resolved this issue for me.

So while this does present a workaround for now, my concern is that we won’t be able to update Aspose.Words past 21.8.0.

@mark.foreman Thank you for additional information. I would suggest you to use stable versions of SkiaSharp, since preview versions might have some issues.
If you do not need some new features introduced in the newver versions of SkiaSharp, I even would suggest you to use 2.80.1 version of SkiaSharp and SkiaSharp.NativeAssets.Linux.NoDependencies. Aspose.Words is tested with tis version.