Aspose Words set license error when using it as part of plugin throws an error

We upgraded from 14.3 Tridion Docs to 15.1 and are running into an issue with setting Aspose license, as we updated our codebase to .Net 4.8 from .Net4.7.2 and updated Aspose to 24.0.1 we are getting the following when using Aspose in a publish plugin. We are unable to replicate this issue when using Aspose in command line script on the batch server, which ruled out it being an Aspose issue.

	EXCEPTION MESSAGE: Could not load type 'System.Runtime.Remoting.RemotingServices' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.	EXCEPTION MESSAGE: Could not load type 'System.Runtime.Remoting.RemotingServices' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089	EXCEPTION MESSAGE: Could not load type 'System.Runtime.Remoting.RemotingServices' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.	EXCEPTION MESSAGE: Could not load type 'System.Runtime.Remoting.RemotingServices' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
The plug-in looks like this

 public void Run(IPublishPostProcessContext context)
 {
     License license = new License();
     try
     {                
         var publishedHtmlDirectory = context.Items["DITAOTOutDirectory"].ToString();  //  get html document
         var publishedHtmlFile = $"{publishedHtmlDirectory}\\index.html";
         var filetemp = new FileInfo(publishedHtmlFile);
         var saveLocation = Path.ChangeExtension(publishedHtmlFile, ".docx");  //  get save to location and file name 
         var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);  //  set license
			\\fails at the line below
         license.SetLicense(@"F:\InfoShare\App\Plugins\Aspose.Total.Net.lic");
         var asposeHtml = new Document(publishedHtmlFile);  //  new up aspose document
         asposeHtml.Save(saveLocation, SaveFormat.Docx);  //  save
     }
     catch (Exception exc)
     {
         _logService.ErrorException("File conversion service failed.", exc);
     }
 }

emoji
  • Hi Akheil,

    The short answer is that several Tridion Docs services, including BackgroundTask, have switched from .NET Framework 4.8 to .NET (Core) 8.0 since Tridion Docs 15.0 released June 2023.

    You are running an InProcess plugin, so it has to match the host. Your plugin library should always have been preferably in .NET Standard 2.0 which is a style of .NET libraries which can be used in .NET Framework 4.x based hosts and in .NET (Core) 3.1+ based hosts.. In your scenario it was a .NET Framework 4.x only library style, in turn you'll have to switch to .NET Standard 2.0 or to .NET (Core) 8+.

    Some background you can find in  Client Tools, Generative AI architecture, Metrics and Platform Support or more specifically in  https://youtu.be/NFI5nhxBDOk?t=461 near minute 7:50

    Best wishes,
    Dave

    emoji
  • Hi Dave,

    Thank you for your response, after upgrading the library to .Net 8, the publish is failing prematurely with the following error.

    System.IO.FileNotFoundException: Could not load file or assembly 'System.ComponentModel.Composition, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
    File name: 'System.ComponentModel.Composition, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Thanks for your help,

    Akheil Jain

    emoji