Issue with Aspose.PDF version 17.1.0

Hi,


We are currently using Aspose.PDF (version 17.1.0.) in production as part of a SharePoint web part. Our libraries are deployed to the GAC. However, when we run function that use Aspose PDF object, the following error occurs during runtime.

Could not load file or assembly ‘Aspose.Foundation, Version=17.1.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.

We use Aspose PDF function to encrypt PDF file using specific algorithm (AES 256).
Here is the example code:

Document doc = new Document(filePath);

doc.Encrypt(password, password, Permissions.ModifyContent, CryptoAlgorithm.AESx256);
doc.Save(filePath);

The exception occurs on the doc.Encrypt line.

I suspect that there may be an issue with missing references or and issue with security access to the GAC assembly from a SharePoint page.

This is an urgent matter as it involves our production deployment. I appreciate a prompt response.

FYI, we use Sharepoint 2010 and .Net Framework ver. 3.5 in our development environment.

Thanks.

Hi There,


Thanks for contacting support.

The issue which you have reported, has already been logged in our issue tracking system as PDFNET-42268. However, there are two workarounds for this issue which currently can be implemented to avoid the trouble.

1. Please do not use assembly.GetTypes(), use assembly.GetExportedTypes() instead like following:

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(@“d:\MyApp\References\Aspose.Pdf.dll”);
// it works fine now and returns all public exported non-obfuscated classes.
var types = assembly.GetExportedTypes();


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

System.Reflection.Assembly assembly = System.Reflection.Assembly.LoadFrom(@“d:\MyApp\References\Aspose.Pdf.dll”);
assembly.CreateInstance(“Aspose.Pdf.Document”);
// it works fine now.
var types = assembly.GetTypes();


The development team is working on resolving the issue and we really hope that its fix will be included in upcoming version of Aspose.Pdf for .NET. I have associated the issue ID with this thread as well, so that you will be notified once issue is resolved. Please be patient and spare us a little time.

We are sorry for the inconvenience.


Best Regards,

Hello Asad Ali,

Could you please give a detail example about solutions you provide?
We have try your solution on our development environtment, and it still throw the same exception.

Assembly assembly = Assembly.LoadFrom(@“C:\Aspose.PDF\Aspose.Pdf.dll”);
assembly.CreateInstance(“Aspose.Pdf.Document”);

Type type = assembly.GetType(“Aspose.Pdf.Document”);

Document doc = (Document)Activator.CreateInstance(type, filePath);

The exception occurs on the Activator.CreateInstance line.

Thanks.

Hello There,


Thanks for writing back.

I have tried to run the code snippet which you have shared, with Aspose.Pdf for .NET 17.4.0 and was unable to notice any exception. Please note that it is always recommended to use latest version of the API as it contains all fixes and enhancements. Please try using latest version of the API and in case you still face any issue, please feel free to contact us.


Best Regards,

Hello Asad Ali,

I already upgrade Aspose Pdf version to 17.4.0. It still not working and throw the same exception.
Have you try it on SharePoint webpart development? Because the exception only happen when we deploy it to GAC as part of Sharepoint webpart. Other than that, it run smoothly.

Thank you.

Hi There,


Thanks for writing back.

We have already observed the same issue which you have just reported and it has been logged as PDFNET-42268 in our issue tracking. I would like to share with you that development team is working to resolve the issue and it is expected that its fix will be included in upcoming release Aspose.Pdf for .NET 17.5.0. The new version of Aspose.Pdf for .NET is expected to be released in this very week or in early next week. Please be patient and spare us little time.

We are sorry for the inconvenience.


Best Regards,