Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Sat Nov 20, 2021 4:21 am

Hi,

We are trying to upgrade our code to .net 6 however spire.doc is turning into a blocker in this case. On linux (not windows) when we are referencing the spire.doc nuget package (which is only available with a net5.0 version) it causes the following error:

Code: Select all
Could not load type 'sprゃ' from assembly 'Spire.Pdf, Version=7.11.1.0, Culture=neutral, PublicKeyToken=663f351905198cb3'.


Here is the stack trace - the error is happening in the constructor of the Document class. It seems to be a problem with the loading of the Spire.PDF binary. I am using the latest nuget version of Spire.Doc.

Code: Select all
at Spire.Doc.Document..ctor()
   at Spire.Doc.Document..ctor(Stream stream)
   at Kalix.Api.Infrastructure.Documents.DocumentConverter.ConvertDocxToPdf(PipeReader docx, PipeWriter output) in /agent/_work/1/s/Kalix.Api.Infrastructure/Documents/DocumentConverter.cs:line 120
  ...


Here is the code that is causing the error:

Code: Select all
using var ms = new MemoryStream();
...
using var doc = new Document(ms); <-- fails on this line


Is there any chance to get a version of Spire.Doc compiled for net6? Unfortunately we have completed a bit of work so it would be a shame to have to roll it all back, we only picked this up in runtime tests.

Cheers,
Felix

felix@kalixhealth.com
 
Posts: 13
Joined: Sat Nov 07, 2015 4:10 am

Sun Nov 21, 2021 12:28 am

Hi,

Follow up to this issue - we were taking a look at the assemblies that were ending up on our server to work out what was happening, and we worked out what was causing the issue - we are using the 'PublishReadyToRun' flag in our dotnet build and that seems to be causing an issue with the build somehow. If we disable that option then it all functions correct in .Net 6.

Here is an example of the publish step we were using:
Code: Select all
dotnet publish Project.csproj -c Release -r linux-x64 -p:PublishReadyToRun=true


Just wanted to put this out here in case you wanted to look at it further. We have disabled this option for now.

Cheers,
Felix

felix@kalixhealth.com
 
Posts: 13
Joined: Sat Nov 07, 2015 4:10 am

Mon Nov 22, 2021 7:36 am

Hello Felix,

Thanks for your inquiry!

Glad to hear that you have resolved this issue yourself. And I did notice that when publishing a project with "PublishReadyToRun=true" in the Linux environment using the .net 6.0 target framework, our Spire.Doc thrown an exception. However, this exception did not appear in the Linux environment of .net 5.0 and below target frameworks.

I have submitted this issue to our Dev team with the ticket SPIREDOC-6994 for further investigations.

If there is any update, we will keep you informed. Sorry for the inconvenience caused.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 726
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Doc