The type initializer for ' ' threw an exception

Hi team,

I am getting below error when converting Word to html. This is happening for only few files having more than 2 page in word documents. I am using .net core.

The type initializer for ' ’ threw an exception.

Aspose code :-

                    Aspose.Words.License license = new Aspose.Words.License();
                    license.SetLicense("Aspose.Total.lic");
                    // Console.WriteLine("Word to html conversion Ends for " + file);
                    Aspose.Words.Document docHtml = new Aspose.Words.Document(fileStream);
                    Aspose.Words.Saving.HtmlSaveOptions opts = new 
                    Aspose.Words.Saving.HtmlSaveOptions(SaveFormat.Html);
                    opts.CssStyleSheetType = CssStyleSheetType.Embedded;
                    opts.TableWidthOutputMode = HtmlElementSizeOutputMode.All;
                    opts.ExportHeadersFootersMode = ExportHeadersFootersMode.None;
                    docHtml.Save(Path.ChangeExtension(fileName, ".html"), opts);

@nitz63

Thanks for your inquiry. Could you please attach your input Word document here for testing? We will investigate the issue on our side and provide you more information.

Hi Tahir,

Thanks for your reply. Below is the inner exception.

InnerException = {System.TypeInitializationException: The type initializer for ‘SkiaSharp.SKImageInfo’ threw an exception. —> System.DllNotFoundException: Unable to load DLL ‘libSkiaSharp’: The specified module or one of its dependencies could not be found.
(Exception fr…

Also i am attaching two doc files. Doc 1 is converting successfullyFiles.zip (22.8 KB)
and doc 2 is not converting. They both are the simple document.

Regards,
Nitin Tyagi

@nitz63

Thanks for sharing the detail. You are facing this issue because Aspose.Words is not properly installed at your end. Please install Aspose.Words for .NET through NuGet.

If you still face problem, please share your working environment e.g. operating system, .NET version etc. here for further testing.

Hi Tahir,

Below are the details.

I have create a .net core web application and selected API template with Docker support of linux i.e application is running as image in docker linux container. Because i have to deploy this WEB API word to html on linux 64bit machine. Also attached whole source code. Please do have a look.

IDE :- VS 2017
Target Framework :- .net core 2.0
Development OS :- Windows 10

From inner exception i can see this is related to libSkiaSharp but i am unable to find this in Nuget. Also i have installed Aspose words from Nuget only.

Our source code and licence file is also attached in same project,

Please do let me know if you need any other info. Below is the final source code.

WebApplication1.zip (715.3 KB)

@nitz63

Thanks for sharing the detail. We will investigate the issue on shared environment and share our findings with you soon.

Hi Tahir,

Thanks. Can you please let me know when this is get resolved.?

@nitz63

Thanks for your inquiry. Aspose.Words does work with docker container. The .NET Standard 2.0 version of Aspose.Words uses SkiaSharp to deal with graphics. Please make sure that you have properly installed the latest version of Aspose.Words for .NET 19.1 through NuGet. The latest version of Aspose.Words contains the SkiaSharp 1.60.3.