简体   繁体   中英

Aspose.Words conversion throw error in Docker

I'm working on .NET Core 2.0 app that converts document to PDF, JPEG, PNG in VS 2017 with Docker support. When I launch app via IIS Express everything works fine, but if I launch app as Docker container in Release mode, then app throws errors.

  1. When I convert to PDF:

    The type initializer for 'SkiaSharp.SKManagedStream' threw an exception.

  2. When I convert to JPEG:

    The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.

How can I resolve that issue? Or it's issue of SkiaSharp or Aspose library?

The reason of the problem is SkiaSharp, it does not contain native libSkiaSharp.so in it's NuGet package. https://github.com/mono/SkiaSharp/issues/288

To work this problem around, I did the following:

  1. Download libSkiaSharp.so from here https://github.com/mono/SkiaSharp/releases/tag/v1.59.3

  2. Created NuGet package using the following nuspec

    <?xml version="1.0" encoding="utf-8"?> <package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd"> <metadata> <id>Aspose.Skia.Linux.Natives</id> <version>1.59.3</version> <title>Aspose.Skia.Linux.Natives</title> <authors>Aspose</authors> <owners>Aspose</owners> <requireLicenseAcceptance>false</requireLicenseAcceptance> <description>Contains skia natives for Linux</description> <dependencies> <group targetFramework=".NETStandard2.0"> <dependency id="SkiaSharp" version="1.59.3" /> </group> </dependencies> </metadata> <files> <file src="C:\\Temp\\libSkiaSharp.so" target="runtimes\\linux-x64\\native\\libSkiaSharp.so" /> </files> </package>

  3. Put the resulting NuGet package into private repository and added reference to it in my .NET Core Web app.

  4. Added reference to Aspose.Words NuGet package.

  5. Modified Dockerfile:

FROM microsoft/aspnetcore:2.0

ARG source

WORKDIR /app

EXPOSE 80

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

COPY ${source:-obj/Docker/publish} .

ENTRYPOINT ["dotnet", "WebApplication1.dll"]

As you can see I added "RUN apt-get update && apt-get install -y libfontconfig1", since libSkiaSharp.so seems depend on it.

I work with Aspose as Developer Evangelist.

It seems like the issue is with respect to the access permission to the .nuget > packages on the server machine. I was facing a similar issue on my server machine where permission for the application pool was not given.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM