Hi,
I am running a project using Aspose Words for .NET using version 21.11.0. When I try to process a document with an image included in it, this error is being thrown.
System.TypeInitializationException: 'The type initializer for 'SkiaSharp.SKObject' threw an
exception.'
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
This exception was originally thrown at this call stack:
SkiaSharp.SkiaSharpVersion.Native.get()
SkiaSharp.SkiaSharpVersion.CheckNativeLibraryCompatible(bool)
SkiaSharp.SKObject.SKObject()
My project is being run inside of a docker container using a debian based linux x64 architecture.
These are the related packages I have installed
- Aspose words 21.11.0
- SkiaSharp 2.80.3
- SkiaSharp.NativeAssets.Linux 2.80.3
- System.Drawing.Common 5.02
This is my Docker file
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
RUN apt-get update && apt-get install -y apt-utils
RUN apt-get install -y libfreetype6
RUN apt-get install -y libfontconfig1
RUN apt-get install -y libgdiplus
RUN apt-get install -y libc6-dev
COPY ["source/Host.DocumentReplace/Fonts/", "/usr/share/fonts/truetype/msfonts/"]
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
RUN apt-get install -y wget
RUN wget https://github.com/google/fonts/archive/main.tar.gz -O gf.tar.gz
RUN tar -xf gf.tar.gz
RUN mkdir -p /usr/share/fonts/truetype/google-fonts
RUN find $PWD/fonts-main/ -name "*.ttf" -exec install -m644 {} /usr/share/fonts/truetype/google-fonts/ \; || return 1
RUN rm -f gf.tar.gz
RUN rm -rf /var/cache/*
RUN apt-get install fontconfig
RUN fc-cache -f
WORKDIR /app
EXPOSE 80
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
WORKDIR /src
COPY ["source/Host.DocumentReplace/Host.Document.Api.csproj", "source/Host.DocumentReplace/"]
COPY ["source/Contracts.Service.Document/Contracts.Service.Document.csproj", "source/Contracts.Service.Document/"]
COPY ["source/Domain.Document/Domain.Document.csproj", "source/Domain.Document/"]
COPY ["source/Utility.Document/Utility.Document.csproj", "source/Utility.Document/"]
COPY ["source/Contracts.Manager.Document/Contracts.Manager.Document.csproj", "source/Contracts.Manager.Document/"]
COPY ["source/Contracts.Resources.Document/Contracts.Resources.Document.csproj", "source/Contracts.Resources.Document/"]
COPY ["source/Services.Document/Services.Document.csproj", "source/Services.Document/"]
COPY ["Handler.Document/Handler.Document.csproj", "Handler.Document/"]
COPY ["Manager.Document/Manager.Document.csproj", "Manager.Document/"]
RUN dotnet restore "source/Host.DocumentReplace/Host.Document.Api.csproj"
COPY . .
WORKDIR "/src/source/Host.DocumentReplace"
RUN dotnet build "Host.Document.Api.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "Host.Document.Api.csproj" \
--configuration Release \
--runtime linux-x64 \
--self-contained false \
--output /app/publish \
-p:PublishReadyToRun=true
FROM base AS final
WORKDIR /var/task
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "bootstrap.dll"]
Any help on this would be greatly appreciated