Error when Save PDF File - Could not load file or assembly 'Aspose.Font'

Hi


I am using Aspose.Pdf 17.2 to load Pdf File
Running the follow code throw exception in the method “Save”

Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(documentStream);

//save updated PDF file
var tmpResultFile = new FileStream(Path.GetTempFileName(), FileMode.Truncate, FileAccess.ReadWrite, FileShare.None, 8192, FileOptions.DeleteOnClose);
pdfDocument.Save(tmpResultFile);
return tmpResultFile;


Exception:

System.IO.FileNotFoundException: Could not load file or assembly ‘Aspose.Font, Version=17.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.
File name: ‘Aspose.Font, Version=17.2.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’
at …ctor()
at .( )
at .​ ​ (Stream )
at Aspose.Pdf.Document.Save(Stream output)
at dbMotion.Transformation.DocumentConversion.AsposeDocBuilder.LoadPdf()
at dbMotion.Transformation.DocumentConversion.AsposeDocBuilder.Save(OutputFormat outputFormat)
at dbMotion.Transformation.DocumentConversion.DocBuilderWorker.Convert()


Hi Yaniv,


Thank you for contacting support. Please send us your source PDF document for the investigation purposes. We will take a closer look and share our findings with you. Your response is awaited.

Hi Yaniv,


Thanks for contacting support.

We already have noticed above mentioned issue and its been logged in our issue tracking system as PDFNET-42106 and product team is working working on fixing this problem and we plan to get it resolved in next release of Aspose.Pdf for .NET 17.5. As soon as we have some further updates, we will let you know.

We are sorry for this inconvenience.

Thanks


Do you have any workaround?

Hi Yaniv,


Thanks for contacting support.

The above stated problem is a known issue and we are working on fixing it. However currently there are two workarounds for this problem.

1.Do not use assembly.GetTypes(), use assembly.GetExportedTypes() instead.

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(@“d:\MyApp\References\Aspose.Pdf.dll”);

var types = assembly.GetExportedTypes(); // <-- it works fine now and returns all public exported non-obfuscated classes.


2. Call assembly.CreateInstance(“Aspose.Pdf.Document”); after LoadFrom(), before GetTypes(). Something like this:

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(@“d:\MyApp\References\Aspose.Pdf.dll”);

assembly.CreateInstance(“Aspose.Pdf.Document”);

var types = assembly.GetTypes(); // <-- it works fine now.

Thanks for you help, but the workaround (both of them does not work for me)


  1. First workaround throw same exception: Could not load file or assembly 'Aspose.Font’
  2. Second workaround throws exception in the method GetType
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)


Please assist

BTW: when do you expect to release Aspose.Pdf 17.5 which contains fix for this issue?


Thx
Yaniv

yaniv.ayalon:
Thanks for you help, but the workaround (both of them does not work for me)

  1. First workaround throw same exception: Could not load file or assembly 'Aspose.Font’
  2. Second workaround throws exception in the method GetType
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)

Hi Yaniv,

Thanks for the acknowledgement.

Can you please confirm if you are using Aspose.Pdf.dll from Nuget package or using it after installation through MSI package.
yaniv.ayalon:
BTW: when do you expect to release Aspose.Pdf 17.5 which contains fix for this issue?
We plan to publish this version within this week or early next week.

Thanks for your answer.


1. I will wait for 17.5 to release, please notify me when its ready.
2. When i use Apsoe.Pdf.dll from nuget packeges (on my local machine) its work fine.
But when I use it in our servers - After installed in with MSI the GAC, the issue occur.
Does it make sense to you?

Yaniv

yaniv.ayalon:
Thanks for your answer.

1. I will wait for 17.5 to release, please notify me when its ready.
2. When i use Apsoe.Pdf.dll from nuget packeges (on my local machine) its work fine.
But when I use it in our servers - After installed in with MSI the GAC, the issue occur.
Does it make sense to you?

Yaniv
Hi Yaniv,

With the release of new version, the issue related to missing packages will be resolved and development team is also working on fixing the issue related to referencing binaries form GAC.

Hi,


Any news regarding this issue?

Hi Yaniv,


Thanks for your patience.

The product team is working on performing unit testing on upcoming release but I am afraid due to some technical limitations, the earlier reported issue is not yet resolved and I am sorry to inform that it’s fix may not be included in upcoming release of Aspose.Pdf for .NET 17.5. However I am in coordination with product team and as soon as we have some further updates regarding its resolution, we will let you know.

We are sorry for this delay and inconvenience.

Hi Yaniv,


Thanks for your patience.

We are pleased to share that the issue reported earlier as PDFNET-42106 is resolved in latest release of Aspose.Pdf for .NET 17.6. Please try using the latest release and in the event of any further query, please feel free to contact.