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

Free Support Forum - aspose.com

Aspose.Words and Aspose.Slides does not work with .NET 6 "Ready to Run"

Hi,
Ready to Run is a feature in .NET Core 3.0 and later where assemblies are precompiled for faster loading (see https://docs.microsoft.com/en-us/dotnet/core/deploying/ready-to-run). However, when we compile with Ready to Run, the SetLicense method for both Aspose.Words and Aspose.Slides fails:

Cannot load type '♣  , Aspose.Words, Version=22.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56'.
   at ☻ .♣  (Int32 ☻, ♣  ♥, Boolean& ♣, Boolean)
   at ☻ .  (Int32 ☻, Boolean ♥)
   at ☻ .♣  (Int32 ☻, ♣  ♥)
   at ☻ .☻  (Int32 ☻)
   at ☻ .  (☻  ☻,   ♥)
   at ☻ .☻  ()
   at ☻ . (Boolean ☻)
   at ☻  (Object ☻)
   at ☻ ? (Object ☻)
   at ☻ .  ()
   at ☻ .☻  (Object ☻, UInt32 ♥)
   at ☻ . (Boolean ☻)
   at ☻ .  (Object[] ☻, Type[] ♥, Type[] ♣, Object[])
   at Aspose.Words.License..ctor_2()
   at Aspose.Words.License..ctor()

We do get the same issue on Aspose.Cells – but the Aspose.Cells team has confirmed that a fix is released this week or the next. See related ticket (not created by me): .NET 6 Support with Linux or non-Windows systems?

Here’s the publish command we run (on Windows):
dotnet publish -r win-x64 -p:PublishReadyToRun=true -c Debug --no-self-contained .\Foobar.csproj

If we exclude these assemlies from ready to run in the project file:

    <PublishReadyToRunExclude Include="Aspose.Cells.dll" />
    <PublishReadyToRunExclude Include="Aspose.Words.dll" />
    <PublishReadyToRunExclude Include="Aspose.Slides.dll" />

then it works great.

We use the latest version of the assemblies, on .NET6.
Cells: 21.1
Words: 22.2
Slides: 22.1

This is essential for us, especially with Aspose, to decrease the initial execution time of various functions. Up until now we have used .NET Framework, but are porting the code that uses Aspose to .NET 6. This is currently a blocker for us to continue the .NET 6 work.

Is this a known issue for Aspose.Words and Aspose.Slides? Is there an ETA for a fix if that is the case?

Thank you in advance.

@hallgeirl Thank you for reporting this problem to us. I have managed to reproduce it on my side, for a sake of correction, the issue has been logged as WORDSNET-23459. We will keep you informed and let you know once it is resolved.

1 Like

Thank you!

Does this issue also cover Aspose.Slides, or do I need to create a ticket for slides as well?

@hallgeirl The created issue covers only Asppose.Words. You should report the same for Aspose.Slides too.

I have created a ticket here:
https://forum.aspose.com/t/aspose-slides-does-not-work-with-net-6-ready-to-run/241751

@hallgeirl Thank you for additional information. We will let you know once this issue is resolved in Aspose.Words.

@hallgeirl We have completed analysis of the issue and here are our findings.
The problem is caused by obfuscation applied to the library. By default renaming feature encode names with non-printable characters. In this case non-printable characters are also used for virtualization methods and classes.
We have tried to publish the sample project with PublishReadyToRun=true using netcore3.1 and net5 - the result binaries work ok. So, it is problem of net6 only.
We have tried to exclude virtualization for Aspose.Words for .NET - net6 fails.
We have tried to exclude renaming for Aspose.Words for .NET - net6 fails.
We have tried to use renaming with printable characters for Aspose.Words for .NET - net6 works OK.
So, using of non-printable characters - is the reason of this issue.

We will also consult with our obfuscator software vendor maybe they can provide a solution for this issue, because renaming with printable characters while obfuscating our code will decreas the library anti-patch protection.

Thanks for the update @alexey.noskov! I appreciate that.

I would recommend you also reach out to the Aspose.Cells team, since they have solved this for Aspose.Cells. They have a new version that seems to work fine with .NET 6 and R2R, and the symptom was identical.
https://forum.aspose.com/t/net-6-support-with-linux-or-non-windows-systems/239366/19
Issue number was CELLSNETCORE-322 according to the person from Aspose in the thread.

@hallgeirl Thank you for sharing this information.

@hallgeirl We have tested Aspose.Words for .Net 22.3 with .net 6.0.200 - it works correctly.
Please update your Aspose.Words for .Net and .net 6 SDK.

Hi @alexeybut,
Unfortunately, not quite there yet. With Ready to Run enabled, it fails with the same error, in the same spot (license initialization).

Did you test it with “Ready to run” enabled? This was the core of the issue here, not general .net 6 support (that was working fine already).

To confirm I also updated my .NET 6 SDK to the latest version (6.0.200) and recompiled the application.

@hallgeirl,
It looks like an floating issue (depends on a build\obfuscating process).
I hope we’ll find a workaround in the nearest days.
I’ll inform you about our results.

1 Like

@hallgeirl,
We have fixed this issue. The fix will be available in the version 22.4.

That’s great to hear!

Is there an ETA for 22.4?

@hallgeirl
We are going to release it in the beginning of April.

1 Like

Thanks for the update! We’ll test this out as soon as we have the new version.

The issues you have found earlier (filed as WORDSNET-23459) have been fixed in this Aspose.Words for .NET 22.4 update also available on NuGet.