azure-aksasposeaspose.words

AKS container crash due to Aspose library


Getting below error and my pod getting crash while generate pdf document using

Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKObject' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, 
    consider setting the LD_DEBUG environment variable:
    /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /app/runtimes/linux-x64/native/libSkiaSharp.so)
    /usr/lib64/dotnet/shared/Microsoft.NETCore.App/8.0.12/libSkiaSharp.so: cannot open shared object file: No such file or directory
    /app/libSkiaSharp.so: cannot open shared object file: No such file or directory
    /app/runtimes/linux-x64/native/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
    /usr/lib64/dotnet/shared/Microsoft.NETCore.App/8.0.12/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
    /app/liblibSkiaSharp.so: cannot open shared object file: No such file or directory
    /app/runtimes/linux-x64/native/libSkiaSharp: cannot open shared object file: No such file or directory
    /usr/lib64/dotnet/shared/Microsoft.NETCore.App/8.0.12/libSkiaSharp: cannot open shared object file: No such file or directory
    /app/libSkiaSharp: cannot open shared object file: No such file or directory
    /app/runtimes/linux-x64/native/liblibSkiaSharp: cannot open shared object file: No such file or directory
    /usr/lib64/dotnet/shared/Microsoft.NETCore.App/8.0.12/liblibSkiaSharp: cannot open shared object file: No such file or directory
    /app/liblibSkiaSharp: cannot open shared object file: No such file or directory
    
       at SkiaSharp.SkiaApi.sk_version_get_milestone()
       at SkiaSharp.SkiaSharpVersion.get_Native()
       at SkiaSharp.SkiaSharpVersion.CheckNativeLibraryCompatible(Boolean throwIfIncompatible)
       at SkiaSharp.SKObject..cctor()
       --- End of inner exception stack trace ---
       at SkiaSharp.SKObject.DeregisterHandle(IntPtr handle, SKObject instance)
       at SkiaSharp.SKObject.set_Handle(IntPtr value)
       at SkiaSharp.SKNativeObject.Dispose(Boolean disposing)
       at SkiaSharp.SKObject.Dispose(Boolean disposing)
       at SkiaSharp.SKBitmap.Dispose(Boolean disposing)
       at SkiaSharp.SKNativeObject.Finalize()

Solution

  • Most likely your application is deployed to Linux server. Aspose.Words for .NET Standard and .NET Core uses SkiaSharp to deal with graphics, to make it work on Linux you have to add reference either to SkiaSharp.NativeAssets.Linux or to SkiaSharp.NativeAssets.Linux.NoDependencies

    If you add reference to SkiaSharp.NativeAssets.Linux, you should also install libfontconfig1 in your system. SkiaSharp.NativeAssets.Linux depends on this library. You can use the following command to install it:

    apt-get update && apt-get install -y libfontconfig1
    

    If you do not have rights to install packages, or other reasons not to install libfontconfig1, you can simply use SkiaSharp.NativeAssets.Linux.NoDependencies, which does not require installation of libfontconfig1.