Exception has been thrown by the target of an invocation when trying to merge pdf documents using aspose.pdf.document.save

I'm receiving a "Exception has been thrown by the target of an invocation" error when attempting to merge two pdf documents using aspose.pdf.document.save.

Code:

strFirstFileLocationAndName = "\\SERVERNAME\FOLDERNAME\1.pdf"

strSecondFileLocationAndName = "\\SERVERNAME\FOLDERNAME\2.pdf"

Dim firstDoc As New Aspose.Pdf.Document(strFirstFileLocationAndName)

Dim secondDoc As New Aspose.Pdf.Document(strSecondFileLocationAndName)

firstDoc.Pages.Add(secondDoc.Pages)

firstDoc.Save(strFirstFileLocationAndName)

Stack Trace:

at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct&

signature, RuntimeType declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature,

RuntimeType declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo

culture)
at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args)
at .Ÿ.(• )
at .“.( , • )
at ..†()
at ..(Stream )
at .€.(Stream )
at Aspose.Pdf.Document.Save(Stream output)
at Aspose.Pdf.Document.Save(String outputFileName)
at LIBRARYNAME.DocumentCreation.MergePDFFiles(String strFirstFileLocationAndName, String strSecondFileLocationAndName) in

C:\FOLDERNAME\DocumentCreation.vb:line 84

Hi,


Thanks for using our products.

I have tested the scenario while using Aspose.Pdf for .NET 7.1.0 in VisualStudio 2005 project running over Windows XP-SP3, where I have specified .NET Framework 2.0 as Target platform and as per my observations, the PDF files are properly being concatenated. Can you please try using the latest release version and in case you still face the same problem or you have any further query, please feel free to contact. We are sorry for this inconvenience.

For your reference, I have also attached the resultant PDF that I have generated. Please take a look.

I updated my application to use Aspose.Pdf for .NET 7.1.0. However, it throws the exact same error. It's also now making the first pdf file unreadable after the attempted save.

A little more info:

I'm using Visual Studio 2010 SP1 to build a web application targeting .NET 4.0.

It works perfectly when deployed to our server running Windows Server 2003.

It throws the above error when deployed to either of our servers running Windows Server 2008 (One is running Standard while the other is running R2 Enterprise).

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback and details.

We will check your issue with Windows Server 2008 environment and will get back to you soon.

Sorry for the inconvenience,

Hi,


Thanks for sharing the details.

I have again tested the scenario where I have used VisualStudio 2011 to create a sample website targeting .NET Framework 4.0, Aspose.Pdf for .NET 7.1.0 and I have used Windows Server 2008 R2 Enterprise and I am unable to notice any issue/error while concatenating the PDF files. I have tested the scenario in both evaluation and licensed mode. Can you please prepare a sample project which can be used to replicate this issue. We are sorry for this inconvenience.

I've pulled the code out into a separate visual studio 2012 web site project which I've attached to this reply. The site runs perfect on my local machine and when published to our DEV server running Windows Server 2003. However, it fails when published to either of our PROD machines running Windows Server 2008. The error is the same as before:

Exception has been thrown by the target of an invocation.

at System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType)
at System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Security.Cryptography.CryptoConfig.CreateFromName(String name, Object[] args)
at .“.(‰ )
at .€.( , ‰ )
at ..‡()
at ..(Stream )
at ..(Stream )
at Aspose.Pdf.Document.Save(Stream output)
at Aspose.Pdf.Document.Save(String outputFileName)
at _Default.Button1_Click(Object sender, EventArgs e)

Thanks for your continued help...

It looks like I have narrowed it down to a FIPS issue. It appears that Aspose.PDF is not FIPS compliant. Is this true?

Hi,<?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

Well, there is a similar issue reported by one of our other user regarding FIPS setting which we
are investigating at the moment. Our development team is unable to reproduce
the issue with the latest version of Aspose.Pdf for .NET. However, I am setting
up the environment of Windows Server 2008 R2 to check the issue regarding FIPS.
I will update you soon regarding my findings.<o:p></o:p>

Sorry for the inconvenience,

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for the delay in response.

I am able to generate the issue regarding FIPS after setting up the test environment. The issue is registered in our issue tracking system with issue id: PDFNEWNET-33438. You will be notified via this forum thread regarding any update against your reported issue.

Sorry for the inconvenience,

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for being patient.

Please add the following configuration to your application configuration file and see if it works fine for you.

Please feel free to contact support in case your face any issue or have any query.

Sorry for the inconvenience,

It had no effect. We are receiving the same error.

Even if it worked this would not be a solution for us since our applications need to be FIPS compliant and this simply bypasses FIPS.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Sorry for a delay in response.

Our development team is further investigating this issue. However, this is a complex issue and it is taking some time to get a fix for it. Issue is basically caused due to the use of MD5 to get hash of data in document saving algorithm which is causing the problem. We will notify you via this forum thread regarding any updates against the issue.

Sorry for the inconvenience.

Any update on this?

Thanks

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for being patient.

I am pleased to inform you that we have implemented our own MD5 algorithm to replace MD5CryptoServiceProvider which we were using previously and which was causing the problem. The new implementation will be available in our upcoming release of Aspose.Pdf for .NET v7.3 (to be released in early September 2012). At the moment we are in process of testing of the new release. You will be notified as soon as the new release is available for download.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-33438) have been fixed in Aspose.Pdf for .NET 7.3.0.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.