System.DllNotFoundException: Unable to load shared library ‘libSkiaSharp

@tahir.manzoor
I have started using Aspose.Word since last week and convert word document to PDF and then its deploy to linux docker. after running 7-8 hours my service where I am using ASPOSE.WORD is down then I up the service and again down after 4-5 hours and on.I see this issue is still exists till today after an year.

Following is my self contained details log:

 log4net: Configuration update mode [Merge].
 log4net: Logger [root] Level string is [ERROR].
 log4net: Logger [root] level set to [name="ERROR",value=70000].
 log4net: Loading Appender [PostgresLogAppender] type: [Markers.Common.Library.Log.PostgresAppender, Markers.Common.Library]
 log4net: Created Appender [PostgresLogAppender]
 log4net: Adding appender named [PostgresLogAppender] to logger [root].
 log4net: Hierarchy Threshold []
 warn: Microsoft.AspNetCore.DataProtection.Repositories.FileSystemXmlRepository[60]
       Storing keys in a directory '/root/.aspnet/DataProtection-Keys' that may not be persisted outside of the container. Protected data will be unavailable when container is destroyed.
 warn: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[35]
       No XML encryptor configured. Key {a2cbbd2b-4c0d-48ce-b1d5-0bf2134802d0} may be persisted to storage in unencrypted form.
 log4net: configuring repository [log4net-default-repository] using XML element
 log4net: Configuring Repository [log4net-default-repository]
 log4net: Configuration update mode [Merge].
 log4net: Logger [root] Level string is [ERROR].
 log4net: Logger [root] level set to [name="ERROR",value=70000].
 log4net: Loading Appender [PostgresLogAppender] type: [Markers.Common.Library.Log.PostgresAppender, Markers.Common.Library]
 log4net: Created Appender [PostgresLogAppender]
 log4net: Adding appender named [PostgresLogAppender] to logger [root].
 log4net: Hierarchy Threshold []
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 log4net: Creating repository for assembly [AWSSDK.S3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604]
 log4net: Assembly [AWSSDK.S3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604] Loaded From [Not supported on .NET Core]
 log4net: Assembly [AWSSDK.S3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604] does not have a RepositoryAttribute specified.
 log4net: Assembly [AWSSDK.S3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604] using repository [log4net-default-repository] and repository type [log4net.Repository.Hierarchy.Hierarchy]
 log4net: repository [log4net-default-repository] already exists, using repository type [log4net.Repository.Hierarchy.Hierarchy]
 log4net: Creating repository for assembly [AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604]
 log4net: Assembly [AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604] Loaded From [Not supported on .NET Core]
 log4net: Assembly [AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604] does not have a RepositoryAttribute specified.
 log4net: Assembly [AWSSDK.Core, Version=3.3.0.0, Culture=neutral, PublicKeyToken=885c28607f98e604] using repository [log4net-default-repository] and repository type [log4net.Repository.Hierarchy.Hierarchy]
 log4net: repository [log4net-default-repository] already exists, using repository type [log4net.Repository.Hierarchy.Hierarchy]
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 warn: Microsoft.AspNetCore.Antiforgery.DefaultAntiforgery[8]
       The 'Cache-Control' and 'Pragma' headers have been overridden and set to 'no-cache, no-store' and 'no-cache' respectively to prevent caching of this response. Any response that uses antiforgery should not be cached.
 Unhandled exception. System.TypeInitializationException: The type initializer for 'SkiaSharp.SKObject' threw an exception.
  ---> System.TypeInitializationException: The type initializer for 'SkiaSharp.SKColorSpace' threw an exception.
  ---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory
    at SkiaSharp.SkiaApi.sk_colorspace_new_srgb()
    at SkiaSharp.SKColorSpace..cctor()
    --- End of inner exception stack trace ---
    at SkiaSharp.SKColorSpace.EnsureStaticInstanceAreInitialized()
    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()

@deychandan

We suggest you please read the following article about using Aspose.Words in Docker. Hope this helps you.
How to Run Aspose.Words in Docker

Hi Tahir,

Your last time guide was really helpful for me. But currently I am facing another kind of issue.

Currently I’m using licenced version of Aspose.Words in my PRODCUTION environment. But it is showing “Evaluation Only…" in my converted PDF.

And in QA and DEVLOPMENT environment working fine.

Following my code snippet which I’m using in my all environment:

In class constructor:
private License license = new License();

Code for Convertion from Word to PDF:

public MemoryStream ConvertWordToPDF(MemoryStream stream)
{
    MemoryStream pdfStream = new MemoryStream();
    // Create a new memory stream.
    MemoryStream outStream = new MemoryStream();
    try
    {
        license.SetLicense(@"Aspose.Words.NET.lic");
        Document doc = new Document(stream);
        // Save the document to stream.
        doc.Save(outStream, Aspose.Words.SaveFormat.Pdf);
        // Convert the document to byte form.
        byte[] docBytes = outStream.ToArray();
        // The bytes are now ready to be stored/transmitted.
        // Now reverse the steps to load the bytes back into a document object.
        pdfStream = new MemoryStream(docBytes);
    }
    catch (Exception ex)
    {
        _logger.LogError(ex, "ConvertWordToPDF");
    }
    finally
    {
        stream.Close();
        outStream.Close();
    }

    return pdfStream;
}

Please let me if I missed anything asap. I’m stuck in my PRODUCTION environment.

2C82F4D25EB8459EA57C8D30783C3EB3[1906377].png (329 Bytes)

536CC0835DA14D29AB75C4B4F803433D[1906378].png (373 Bytes)

04C8351B9F22448D857542B3B53A320E[1906379].png (445 Bytes)

418E4969F45D45B5B9749605CFE07205.png (7.05 KB)

45AE9D9FCACD4107AFDAE41F75F92442.png (83 Bytes)

@deychandan

Please remove old license from your application and disk and use only new/correct license.

If you still face problem, please post your license file via private message . In order to send a private message with attachment, please click on my name and find “Message” button. Please check the attached image. send message.png (20.7 KB)

We will investigate the issue with your license file on our end and provide you more information.

P.S. Please do not share your license file publicly in forum threads.

Thanks Tahir. You suggestion remove old license and use new license work for me.

2C82F4D25EB8459EA57C8D30783C3EB3[1906377].png (329 Bytes)

536CC0835DA14D29AB75C4B4F803433D[1906378].png (373 Bytes)

04C8351B9F22448D857542B3B53A320E[1906379].png (445 Bytes)

418E4969F45D45B5B9749605CFE07205.png (7.05 KB)

45AE9D9FCACD4107AFDAE41F75F92442.png (83 Bytes)

@deychandan

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi Tahir,

After a long time currently I have faced a new issue while converting DOCX to PDF. Previously it was worked. Following the issue details.

(Attachment ASPOSE_Issue.txt is missing)

Hi Tahir,

After a long time currently I have faced a new issue while converting DOCX to PDF. Previously it was worked. Following the issue details.

  1. My application working fine in local environment. But not working the hosted version in AWS.

  2. Images not showing in generated PDF file. But when I try to download the DOCX it’s showing perfectly.

My logic are written like… I have a DOCX file with megrefield tag, I have replace those using OpenXML and returned MemoryStream and after that convert those files into a ZIP file and convert those files in PDF using ASPOSE and download. Sample code attached.

I am using “Aspose.Words” version 20.5.0 licence. I’m also using “Aspose.PDF” version 21.5.0 licence in same CS file.

Could you please check this on priority as it’s my PRODUCTION issue.






ASPOSE_Issue.zip (2.71 KB)

@deychandan Most likely your application is deployed to Linux server, but the development environment is Windows.
Aspose.Words for .NET Standard 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.

Also, please make sure libSkiaSharp.so is properly deployed into your production environment. In addition you might find the article about using Aspose.Words in AWS Lambda useful.

Hi Alexey,

Your suggestion works for me. Thanks a lot.