New Aspose.Words.Document(path-AsposeLoadOptions=Auto) gives {"The document appears to be corrupted and cannot be loaded."}

Hi

Using latest .Net2 DLL version 14.8.0 when opening the attached Word document with Load Options LoadFormat set to Auto or Docx I get:

“The document appears to be corrupted and cannot be loaded.”

If the document is opened without the Load Options the error does not occur.

VB.net code:

Try

Dim AsposeLoadOptions As New Aspose.Words.LoadOptions(Aspose.Words.LoadFormat.Auto)

If Not String.IsNullOrEmpty(iPassword) Then AsposeLoadOptions.Password = iPassword

nDoc = New Aspose.Words.Document(_DocumentPath, AsposeLoadOptions)

pCount = nDoc.PageCount

Catch ex As Exception

pCount = 0

End Try

Please advise

(The document is an extract from a much larger document; the same error occurs with both documents)

Thanks for your attention

Hi Jeff,

Thanks for your inquiry. After an initial test with Aspose.Words 14.8.0, I was unable to reproduce this issue on my side (please see attached out-aw-14.8.0.dox).

Please make sure you have attached the correct document with your last post. To make sure, please download this file from here and try loading it with Aspose.Words for .NET and see if it is still reproducible. Can you please also attach the original document here for testing?

Best regards,

Thanks for the reply.

I’ve downloaded the actual uploaded docx from this posting and tried again and it fails the same.

I’ve downloaded your out-aw-14.8.0.docx and that fails with same message. Please see attached screen capture jpg from VS2010 from Function at point of failure with immediate window showing input path and output exception.

Full size original document still fails but I cannot upload that as it is confidential.

I have another document that fails the same Doc1(18).docx, also attached.

Please note all open fine when not using LoadOptions.

Hi Jeff,

Thanks for your inquiry. I am afraid, I was still unable to reproduce this issue on my side. Please create a standalone runnable console application (with source code) that helps us reproduce your problem on our end and attach it here for testing. As soon as you get this simple application ready, we’ll start further investigation into your issue and provide you more information. Thanks for your cooperation.

Best regards,

V2010 console solution that reproduces error is in the AsposeWordsDocOpenFault.zip file at the attached url.

I’ve removed the Aspose.Total.lic from the zip, therefore VS2010 will show the file as missing from 2 locations.

If you are still unable to repro the problem, perhaps you have a debug instance of the dll or a version that does logging that I could use locally?

Hi Jeff,

Thanks for your inquiry. Please make the following changes in your code to correct this problem:

Private Function
OpenAsposeWordDocument(ByVal path As String, ByRef strErrorMessage As String, Optional ByVal iPassword As String = "") As Aspose.Words.Document
Dim nDoc As Aspose.Words.Document = Nothing
Try
'jrm with version 14.8 Aspose.Words.dll we may get "The document appears to be corrupted and cannot be loaded" when using LoadOptions LoadFormat=Auto or Docx, so we may not be able to use passwords till this is fixed
Dim AsposeLoadOptions As New Aspose.Words.LoadOptions()
AsposeLoadOptions.LoadFormat = Aspose.Words.LoadFormat.Docx
'If Not String.IsNullOrEmpty(iPassword) Then AsposeLoadOptions.Password = iPassword
nDoc = New Aspose.Words.Document(path, AsposeLoadOptions)
Catch ex As Exception
'jrm - try to open without the LoadOptions
Try
strErrorMessage = "With Load Options " & ex.Message
nDoc = New Aspose.Words.Document(DocumentPath)
strErrorMessage += vbCrLf & "OK without Load Options"
Catch ex2 As Exception
strErrorMessage += ex.Message
End Try
End Try
OpenAsposeWordDocument = nDoc
End Function

I hope, this helps.

Best regards,