Free Support Forum - aspose.com

Word doc throws error about being corrupt

When opening the attached document with aspose.word, an error is thrown that it thinks the document is corrupt, but i can open up the document just fine in Word. ideas on why?

sample code:

return new Document(new MemoryStream(inputFile));

error thrown:

Word.Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at xaa035fc640f94856.xeab2ca1efdce6a65.get_xe6d4b1b411ed94b5(Int32 xc0c4c459c6ccbd00) at xaa035fc640f94856.xc2aef0a338be67ef.xdde7b5f326d9a3e1(Int32 xc0c4c459c6ccbd00) at x16f9a31f749b8bb1.x32eac27632acc346.x3fcc6938e0108016(Char x12f11d52c2c4d003, Int32 x2865e605e9fbfb80, xeedad81aaed42a76 x789564759d365819, xa52f2632c0ffdfaf xe08a26cc2b49f3aa) at x16f9a31f749b8bb1.x32eac27632acc346.xdf2cafeb128b2de9(xeedad81aaed42a76 x789564759d365819, xa52f2632c0ffdfaf xe08a26cc2b49f3aa, x98d75821045fe9bd xbb8131fb9e06f47f, Int32 xd4f974c06ffa392b, Int32 x961016a387451f05, Boolean x2ce649b040466d4d) at x16f9a31f749b8bb1.x32eac27632acc346.xf59aaff7aa68ace1(x1a78664fa10a3755 x062aae8c9613eeaa) at x16f9a31f749b8bb1.x32eac27632acc346.xb61b92627231b7a8(xb3ad27290106eaf4 x708efeab5b620f36) at x16f9a31f749b8bb1.x32eac27632acc346.xbac2e778f3c6bad1(x98d75821045fe9bd xbb8131fb9e06f47f) at x16f9a31f749b8bb1.x32eac27632acc346.x1f490eac106aee12(Int32 x828697433249d659, Int32 x961016a387451f05) at x16f9a31f749b8bb1.x32eac27632acc346.x7319f5f5433dca3a(HeaderFooterType xa685fef1a31f5d4d) at x16f9a31f749b8bb1.x32eac27632acc346.x709a32d98832a838() at x16f9a31f749b8bb1.x32eac27632acc346.xbac2e778f3c6bad1(x98d75821045fe9bd xbb8131fb9e06f47f) at x16f9a31f749b8bb1.x32eac27632acc346.x1f490eac106aee12(Int32 x828697433249d659, Int32 x961016a387451f05) at x16f9a31f749b8bb1.x32eac27632acc346.x1f490eac106aee12() at x16f9a31f749b8bb1.x0f8a9a895bdf560e.x06b0e25aa6ad68a9() at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) --- End of inner exception stack trace --- at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) at Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) at Aspose.Words.Document..ctor(Stream stream, LoadOptions loadOptions) at Aspose.Words.Document..ctor(Stream stream) at Zywave.Shared.Components.DAL.OfficeEngine.BuildEngines.Doc.Open(Byte[] inputFile) in C:\projects\Services Shared\OfficeEngine\Trunk\Data\BuildEngines\Doc.cs:line 29 at Zywave.Shared.Components.SAL.OfficeEngine.Services.BuildEngines.Doc.Build(Byte[] inputFile, KeyValuePair`2[] mergeFields, Byte[] logoFile, Decimal top, Decimal left) in C:\projects\Services Shared\OfficeEngine\Trunk\Services\BuildEngines\Doc.cs:line 51 at Zywave.Shared.Components.SAL.OfficeEngine.Services.OfficeEngineService.Build(Byte[] inputFile, FileType fileType, KeyValuePair`2[] mergeFields, Byte[] logoFile, Decimal top, Decimal left, Boolean isDocToPdf) in C:\projects\Services Shared\OfficeEngine\Trunk\Services\OfficeEngineService.cs:line 127Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded. ---> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index at System.Collections.ArrayList.get_Item(Int32 index) at xaa035fc640f94856.xeab2ca1efdce6a65.get_xe6d4b1b411ed94b5(Int32 xc0c4c459c6ccbd00) at xaa035fc640f94856.xc2aef0a338be67ef.xdde7b5f326d9a3e1(Int32 xc0c4c459c6ccbd00) at x16f9a31f749b8bb1.x32eac27632acc346.x3fcc6938e0108016(Char x12f11d52c2c4d003, Int32 x2865e605e9fbfb80, xeedad81aaed42a76 x789564759d365819, xa52f2632c0ffdfaf xe08a26cc2b49f3aa) at x16f9a31f749b8bb1.x32eac27632acc346.xdf2cafeb128b2de9(xeedad81aaed42a76 x789564759d365819, xa52f2632c0ffdfaf xe08a26cc2b49f3aa, x98d75821045fe9bd xbb8131fb9e06f47f, Int32 xd4f974c06ffa392b, Int32 x961016a387451f05, Boolean x2ce649b040466d4d) at x16f9a31f749b8bb1.x32eac27632acc346.xf59aaff7aa68ace1(x1a78664fa10a3755 x062aae8c9613eeaa) at x16f9a31f749b8bb1.x32eac27632acc346.xb61b92627231b7a8(xb3ad27290106eaf4 x708efeab5b620f36) at x16f9a31f749b8bb1.x32eac27632acc346.xbac2e778f3c6bad1(x98d75821045fe9bd xbb8131fb9e06f47f) at x16f9a31f749b8bb1.x32eac27632acc346.x1f490eac106aee12(Int32 x828697433249d659, Int32 x961016a387451f05) at x16f9a31f749b8bb1.x32eac27632acc346.x7319f5f5433dca3a(HeaderFooterType xa685fef1a31f5d4d) at x16f9a31f749b8bb1.x32eac27632acc346.x709a32d98832a838() at x16f9a31f749b8bb1.x32eac27632acc346.xbac2e778f3c6bad1(x98d75821045fe9bd xbb8131fb9e06f47f) at x16f9a31f749b8bb1.x32eac27632acc346.x1f490eac106aee12(Int32 x828697433249d659, Int32 x961016a387451f05) at x16f9a31f749b8bb1.x32eac27632acc346.x1f490eac106aee12() at x16f9a31f749b8bb1.x0f8a9a895bdf560e.x06b0e25aa6ad68a9() at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) --- End of inner exception stack trace --- at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) at Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) at Aspose.Words.Document..ctor(Stream stream, LoadOptions loadOptions) at Aspose.Words.Document..ctor(Stream stream) at Zywave.Shared.Components.DAL.OfficeEngine.BuildEngines.Doc.Open(Byte[] inputFile) in C:\projects\Services Shared\OfficeEngine\Trunk\Data\BuildEngines\Doc.cs:line 29 at Zywave.Shared.Components.SAL.OfficeEngine.Services.BuildEngines.Doc.Build(Byte[] inputFile, KeyValuePair`2[] mergeFields, Byte[] logoFile, Decimal top, Decimal left) in C:\projects\Services Shared\OfficeEngine\Trunk\Services\BuildEngines\Doc.cs:line 51 at Zywave.Shared.Components.SAL.OfficeEngine.Services.OfficeEngineService.Build(Byte[] inputFile, FileType fileType, KeyValuePair`2[] mergeFields, Byte[] logoFile, Decimal top, Decimal left, Boolean isDocToPdf) in C:\projects\Services Shared\OfficeEngine\Trunk\Services\OfficeEngineService.cs:line 127

<!–[if gte mso 10]> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0pt 5.4pt 0pt 5.4pt; mso-para-margin:0pt; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:SimSun; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:Arial; mso-bidi-theme-font:minor-bidi;}

<![endif]–>

Hi

Thanks for your request. I cannot reproduce the problem on my side. I can successfully open/save your document on my side. I used the latest version of Aspose.Words for testing. You can download the latest version from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,