Word to Html Conversion giving Type Initialization Exception only on Linux Machines

We have built a .Net core based webservice, And, We are using the Aspose.Words for .Net to convert Word to HTML. This works fine in Windows machines. But I get the following exception when I run the same code n a Linux environment. We have installed Docker on the Linux machine and are running the webservice in Docker Containers.

Please guide us in resolving this issue. Let us know if you need more details.
The Type initializer for ’ ’ threw an exception. at Aspose.Words.Rendering.ShapeRendered…ctor(ShapeBase shape)

This exception occurs only when the input document has images.

@SnehaPurohit

.NET Standard 2.0 version of Aspose.Words uses SkiaSharp to deal with graphics. To make it work in Linux container it is required to add Linux native Skia library. Please add reference to SkiaSharp.NativeAssets.Linux.

I tried adding a Package reference.
</ItemGroup/>
</PackageReference Include=“SkiaSharp.NativeAssets.Linux” Version=“1.68.0”/>
<//ItemGroup>

Also added a using statement in the .cs file where conversion from word to html is called.
using SkiaSharp;

But this did not help. I still get the same error. Kindly guide us on the same.

@SnehaPurohit

Please attach the following resources here for testing:

  • Your input Word document.
  • Please create a standalone console application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

I am attaching a zip file containing sample console application. It also has a sample word document. The code works fine in Windows Environment. But In Linux Environments, the paragraphs containing images are not converted. Throws an exception The Type initializer for ’ threw an exception.

Please note that our actual code is a Webservice running in a Docker Container with “microsoft/dotnet:2.2-sdk-alpine” as Base image.

As described above I have tried adding reference to Linux Native Skia Library. But it did not work.
This is an urgent issue. Kindly respond as soon as possible.SampleApp.zip (872.9 KB)

@SnehaPurohit

Unfortunately, we have not found the attachment with your post. Please attach it again.

Edited my earlier post to attach the zip file.SampleApp.zip (872.9 KB)

@SnehaPurohit

We have published the application for Linux operating system and tested the scenario. We have not found the shared issue while using the latest version of Aspose.Words for .NET 19.6. So, please use Aspose.Words for .NET 19.6.

We tried the following:

  1. Added package Reference “SkiaSharp.NativeAssets.Linux” Version=“1.68.0”.
  2. Upgraded Aspose.Words to version “19.6.0”.
  3. Manually copied libSkiaSharp.so and libHarfBuzzSharp.so in the app directory.

Still the issue remains unresolved. Please note this could be an issue with Web based applications (ASP.Net Core).

Below is the stack trace of the error:

The type initializer for ’ ’ threw an exception.
at …ctor(PointF , SizeF , Byte[] , )
at .(Shape , , ​ )
at .(Shape , ​ , , )
at .( , , , Boolean)
at .( , , Boolean )
at .( , , Boolean )
at .( , Boolean )
at Aspose.Words.Rendering.ShapeRenderer…ctor(ShapeBase shape)
at .(Shape , )
at .(ShapeBase , )
at .(ShapeBase )
at .(ShapeBase )
at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.AcceptChildren(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.AcceptCore(DocumentVisitor visitor)
at .(Section )
at . ()
at .()
at . )
at )
at Aspose.Words.Document. , SaveOptions )
at Aspose.Words.Document.(Stream , String , SaveOptions )

@SnehaPurohit

Could you please ZIP your web application along with all DLL files to Dropbox or any other file hosting service and share the download link here for further testing.

Moreover, please share the complete steps that you are using to reproduce this issue at our end.

Thanks for your cooperation.