Hi Aspose Support Team,
I encountered the following error while stamping a PDF document using Aspose.PDF in a .NET Core 3.1 application running on Amazon EC2 (Linux).
The same code and configuration work perfectly on Windows, but fail on Linux due to a libSkiaSharp loading issue.
I have also included the required fonts within the project folder itself.
Error Log
Unhandled exception. System.TypeInitializationException: The type initializer for ...
---> System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' ...
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)
Systemd reported:
xxxxx.service: main process exited, code=killed, status=6/ABRT
xxxxx.service entered failed state.
Environment Details
- .NET Core: 3.1
- OS: Amazon EC2 Linux (x86_64)
- Aspose.PDF: 21.6.0
- SkiaSharp: 2.88.6
- SkiaSharp.NativeAssets.Linux: 2.88.6
- Status: Works fine on Windows, issue only in Linux
Project File Snippet
<ItemGroup>
<Content Include="ProductionServicev2\Fonts\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="14.9.0" />
<PackageReference Include="PdfSharp.Core" Version="1.0.0" />
<PackageReference Include="PdfiumViewer" Version="2.13.0" />
<PackageReference Include="AWSSDK.Textract" Version="3.7.501.4" />
<PackageReference Include="Aspose.PDF" Version="21.6.0" />
<PackageReference Include="SkiaSharp" Version="2.88.6" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.6" />
</ItemGroup>
Troubleshooting Performed
I verified that libSkiaSharp.so exists under multiple runtime paths:
/home/ec2-user/app/api/runtimes/linux-x64/native/libSkiaSharp.so
/home/ec2-user/app/wfserver/runtimes/linux-x64/native/libSkiaSharp.so
Then I checked its dependencies:
ldd /home/ec2-user/app/wfserver/runtimes/linux-x64/native/libSkiaSharp.so
libfontconfig.so.1 => not found
After installing the missing dependencies:
sudo yum install -y fontconfig freetype libpng libjpeg-turbo expat libX11 libxcb libXext libXrender
All dependencies resolved successfully, and the PDF stamping started working fine after a server restart.
Question
Since the same setup works fine on Windows but fails on Linux until dependencies are manually installed,
is there a recommended way to bundle or include these required native dependencies (like libfontconfig, libfreetype, etc.)
programmatically or during deployment — so that manual installation via yum on the Linux server isn’t required?
Any suggestions to make the Aspose.PDF + SkiaSharp setup fully self-contained for Linux environments would be greatly appreciated.