We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Hosting Aspose dotnetcore 3.1 in Alpine Linux container is not working


While hosting aspose on dotnetcore3.1 in an Alpine based container I get the following error message when converting any type of Aspose files (I have tried both Words and Cells):
System.NullReferenceException: Object reference not set to an instance of an object.
\n at .(Type )\n at .(Object[] )\n at .(Object[] , Type[] , Type[] , Object[] \b)\n at .(Stream , String , Object[] , Type[] \b, Type[] , Object[] )\n at .(Stream , String , Object[] )\n at .(Stream , String , Object[] )\n at Aspose.Words.License.SetLicense(Stream stream)\n at AsposeLinuxTest.FileConverter.API_Aspose.AsposeFileConverter.SetAsposeLicense(DocumentType docType)\n at AsposeLinuxTest.FileConverter.API_Aspose.AsposeFileConverter.ConvertWordToPdfa(String fileToConvert, String destination, DocumentType doctType)\n at AsposeLinuxTest.FileConverter.API_Aspose.AsposeFileConverter.ConvertToPdfAsync(ConfigWrapper configWrapper, DocumentType docType, String fileToConvert, String destination, Int32 recursionLevel)\n

When hosting on Windows the same project, it works fine.

I have googled some topics, so I have added some extra code, but note that these changes did not change the error message in any way.

Conversion code:
private static void ConvertWordToPdfaLinux(string fileToConvert, string destination, Stream licenseStream)
var wordLicense = new Aspose.Words.License();

		var doc = new Aspose.Words.Document(fileToConvert);
		doc.FontSettings.SetFontsFolder("/fonts", true); // This folder contains font used in the document
		var options = new Aspose.Words.Saving.PdfSaveOptions
			SaveFormat = Aspose.Words.SaveFormat.Pdf,
			Compliance = Aspose.Words.Saving.PdfCompliance.PdfA1b,
			ExportDocumentStructure = true // This will include Structured Document Tags (SDT) in the PDF.
		doc.Save(destination, options);

Alpine Linux container creation relevant code:

COPY fonts/ /fonts
RUN apk add libgdiplus --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ --allow-untrusted
RUN ln -s libgdiplus.so /app/gdiplus.dll

After starting up the container:

  • The “/fonts” folder contains .ttf files of the font.
  • The “/app” folder contains all dotnetcore3.1 files + the program + the “gdiplus.dll” file we created.
  • I have made sure the path to fileToConvert and destination is correct Linux format and the fileToConvert exists when entering the method

Any suggestions on how to fix this issue?

EDIT additional clarifying info:
The content of the “/app” folder is the result of running a dotnet publish that is selfcontained and targeting linux-musl-x64. This is something I have a lot of experience with in other containers with same setup. Command ran:
dotnet publish Source/AsposePdfConverter.csproj --configuration Release -p:MvcRazorCompileOnPublish=false --runtime linux-musl-x64 --self-contained=true /p:PackageAsSingleFile=false /p:PublishTrimmed=true --output Source/AsposePdfConverter/bin/Release/PublishOutput/Linux/AsposePdfConverter

The content of the PublishOutput/Linux/AsposePdfConverter folder is then copied into the “/app” folder in the container.

In order to be able to run dotnet publish in this way, I had to also add the following extra references:
PackageReference Include=“System.Collections” Version=“4.3.0” />
PackageReference Include=“System.Diagnostics.Debug” Version=“4.3.0” />
PackageReference Include=“System.IO.FileSystem.Primitives” Version=“4.3.0” />
PackageReference Include=“System.Runtime.Extensions” Version=“4.3.1” />
PackageReference Include=“System.Runtime.Handles” Version=“4.3.0” />
PackageReference Include=“System.Runtime.InteropServices” Version=“4.3.0” />

Version of Aspose.Words = 19.9.0
Version of Aspose.Cells = 19.8.0


Thanks for contacting support.

Would you kindly try using latest version of both Aspose.Cells and Aspose.Words APIs in your environment. In case issue still persists, we request you to please share Alpine Linux image where the dotnetcore 3.1 based solution using Aspose products is deployed along with the steps to reproduce the problem. We will reproduce the issue here and may log an investigation ticket if required.

I updated to latest Aspose.Words and created an open source implementation you guys can look at:

Notice that the error message here is different from what I initially got. It might be related to the updated Aspose.Words package. The file ‘System.Void.dll’ is indeed not present in the container folder, so the error message is correct.

I have not included code for SetLicense logic here, as it is open scource. Please also modify the code to set commercial license to make sure that works OK as that is where I got my original error message.


We suggest you please read the following article to run Aspose.Words with Alpine Linux container. Hope this helps you.
How to Run Aspose.Words in Docker

Please install the latest version of Aspose.Words for .NET through NuGet.

If you still face problem, please share the following detail here for testing.

  • Please remove Aspose.Cells from your application and set license for Aspose.Words.
  • Are you facing this issue only at Alpine based container?
  • Regarding ‘System.Void.dll’, are you facing this issue at compile time?

Please do the same for Aspose.Cells and share your findings here for further testing. Thanks for your cooperation.

Aspose.Words for .Net Standard depends on SkiaSharp that requires native assets. To run on Alpine Linux, please, add Nuget reference either to Goelze.SkiaSharp.NativeAssets.AlpineLinux or SkiaSharp.NativeAssets.Linux.NoDependencies, as described in the article Tahir suggested.