Aspose Words and .NET Core 2.0 error

Hello,
I have tried to run most simple app to convert a docx to html with aspose words .NET Standard 2.0 lib and .NET Core 2.0 console app (tried both x64 and x86 Win10 builds), but I get following error:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Aspose.Words.Document' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
   at? .()
   at Aspose.Words.Document..cctor()
   --- End of inner exception stack trace ---
   at Aspose.Words.Document..ctor(String fileName)
   at NetCoreTestConsoleApp.Program.Main(String[] args) in NetCoreDCPTestConsoleApp\Program.cs:line 15

Here is C# code:

    class Program
    {
        static void Main(string[] args)
        {
            // Load the document from disk.
            if (args.Length > 0)
            {
                Document doc = new Document(args[0]);
                HtmlSaveOptions options = new HtmlSaveOptions();
                doc.Save(Path.GetFileNameWithoutExtension(args[0]) + ".html", options);
                Console.WriteLine("\nDocument converted to html successfully.");
            }
            else
                Console.WriteLine("Missing doc");
        }
    }

Any idea why I get this error?

Thanks

@leftofcentre,

Thanks for your inquiry. Please use latest version of Aspose.Words for .NET 18.4. The ‘netstandard2.0’ and ‘netstandard2.0_AuthenticodeSigned’ folders contain Aspose.Words’ assemblies to use with frameworks that implement .NET Standard 2.0 such as .NET Core 2.0. Please make sure that you are using the correct DLL.

If you still face problem, please ZIP and attach your input Word document here for testing. We will investigate the issue and provide you more information on this.

Checked 18.4 and it’s the same error. Any docx fails, attached project zip and simple test doc.

NetCoreDCPTestConsoleApp.zip (871 Bytes)

Hello.zip (9.0 KB)

@leftofcentre,

Thanks for your inquiry. We are working over your query and will get back to you soon.

@leftofcentre,

I am afraid, we are still unable to reproduce this issue on our end when using the latest version of Aspose.Words for .NET i.e. 18.4. Please try running the following .NET Core 2.0 Console App on your end:

DotNetCoreApp.zip (251.6 KB)

My project zip for sure was not working, but I know why now. Your project is using Aspose Words from NuGet which is adding several dependencies:
net_core_dependencies.png (9.8 KB)

When I added Aspose Words via NuGet all is OK, I was adding only Aspose Words dll from .NET Standard 2.0 folder, that’s why some dlls were missing.

Thanks

@leftofcentre,

Thanks for the additional information. We suggest you please always install Aspose.Words for .NET via NuGet.

Hi again,
currenty I have other issue. When I publish that .NET Core 2.0 app for any version of ubuntu.16.04-x64 I can not run it because I get an error that Aspose 18.4 was not found:
error (83.2 KB)

But Aspose dll is in publish folder:
aspose dll (75.3 KB)

Any clue why I get this error? .NET Core 2.0 was installed OK on Ubuntu …

Thanks

@leftofcentre,

How are you publishing your application on Ubuntu?

Considering the .NET Core 2.0 Console Application that I shared in my previous post, please list all steps that we can follow to reproduce the same problem on our end.

Hi,

  1. build .NET core 2.0 app with Aspose Words on Windows10 in VS 2017
  2. then open cmd line in folder where project file is and run this command:
    dotnet publish -r ubuntu.16.04-x64
  3. Copy output ubuntu build folder to Ubuntu 16.04 LTS
  4. After installing .NET Core 2.0 on ubuntu (info from here: https://github.com/dotnet/docs/blob/master/docs/core/linux-prerequisites.md) I run that app and get that error mentioned in previous message.

If you need more info let me know…

Thanks

@leftofcentre,

Thanks for sharing the detail. Could you please check Aspose.Words DLL in publish folder either it exists or not? If it exists and you still face problem on Ubuntu, we will setup .NET Core 2.0 on Ubuntu, test this scenario, and share our findings with you. Thanks for your cooperation.

Yes, Aspose.Words.dll is in publish folder. Please see my screenshot showing aspose dll in publish folder. Already sent it on April 06th.

PS. Build for Windows x64 .NET Core 2.0 works fine…

@leftofcentre,

Thanks for sharing the detail. Please spare us some time to setup Ubuntu operating system and .NET Core 2.0. We will investigate the issue on our side and provide you more information. Thanks for your cooperation.

@leftofcentre,

Thanks for your patience.

We have tested the scenario at Ubuntu and have not found the shared issue. Please check the attached image for detail. DOTNET_Core_Test.jpg (255.7 KB)

We executed the file “VS2017_Core” (the project name) that exists under publish folder. Please execute the “NetCoreDCPTestConsoleApp” file that is under publish folder.

Hello,
OK, it works when running app from publish folder. I’m new to .NET Core so I thought that I have to run app from main root folder. I did not notice the same app from publish folder. A bit confusing why app is in root and publish folder, I have to learn more about .NET Core :wink:

But I have got other issue now, see this error when converting docx with a least one image to html:
ubuntu_save_as_html_issue.jpg (155.1 KB)

Any ideas what’s wrong?

Thanks

@leftofcentre,

Thanks for your inquiry. The System.DllNotFoundException is thrown when a DLL specified in a DLL import cannot be found. Please make sure that you export your project for Ubuntu correctly. This exception is thrown due to missing of libSkiaSharp that is required for Aspose.Words for .NET.

I think my .NET Core build is published OK. Ubuntu publish folder has SkiaSharp.dll but there no libSkiaSharp.so in it. SkiaSharp.dll is looking for this file …
Maybe it’s .NET Core 2.0 issue on Ubuntu because all is OK on Windows…

Did you try converting a doc with image like I wrote?

@leftofcentre,

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

@leftofcentre,

We have logged this problem in our issue tracking system as WORDSNET-16749. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

A post was split to a new topic: Unable to load DLL ‘libSkiaSharp’