Aspose.Words.FileCorruptedException by creating new Document from a docx file

Hi,

I am using Aspose.Words for editing files that are stored in an IMAGE column in MS SQL Server 2005 database.
Here is the code that creates a Document after the content is retrieved from the database.

MemoryStream _inputStream = new MemoryStream(content);
Document _document = new Document(_inputStream);

The file is loaded in a byte array and passed as a MemoryStream, but the Document constuctor throws the following exception.

Exception: Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
Stack Trace:
[FileCorruptedException: The document appears to be corrupted and cannot be loaded.]
Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) +2176
Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) +213
Aspose.Words.Document..ctor(Stream stream, LoadOptions loadOptions) +115
Aspose.Words.Document..ctor(Stream stream) +39
CMS.Web.Helpers.AsposeWordHelper..ctor(FileNetContent content) in ...:26
CMS.Web.ServicePoint.Request.GetApprovedVersion() in ...:115
CMS.Web.ServicePoint.Request.ProcessRequest(HttpContext context) in ...:27
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +341
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69

Inner Exception: Object reference not set to an instance of an object.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
xda075892eccab2ad.xc1b08afa36bf580c.xa9aaee2edd3cd025(String x971e83bc97861294, Byte[] xf9a0d04800d70471, Int32 x10aaa7cdfa38f254) +138
x79490184cecf12a1.xc37fee571c29ba92.xdafccb198ba91439() +386
x79490184cecf12a1.xc37fee571c29ba92.x2506b757d67702ec() +372
x79490184cecf12a1.xc37fee571c29ba92.x902b6f807c71becd(x3dabda6865ed239d x8ad4cdceb54e447f) +227
x79490184cecf12a1.xc37fee571c29ba92.xd4c5b858945b0ab2(x3dabda6865ed239d x8ad4cdceb54e447f) +193
x79490184cecf12a1.xc37fee571c29ba92.x06b0e25aa6ad68a9(xa52ef41af20225f0 xe134235b3526fa75) +1071
x79490184cecf12a1.xa52ef41af20225f0.DoRead() +119
x79490184cecf12a1.x11e1346c12ead315.x06b0e25aa6ad68a9() +131
x79490184cecf12a1.xae13d15563a3a703.x748a2047fcb706ad() +149
x79490184cecf12a1.xae13d15563a3a703.x06b0e25aa6ad68a9() +69
Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46) +1506
I am using Aspose.Words version 11.1.0.0. for .NET. The problem appears when working with some .docx files, espeacially when they are created in Office 365. A file that reproduces the issue is attached.

Can someone help. Thanks in advance.

Hi Veselin,

Thanks for your inquiry. I have tested the scenario using latest version of Aspose.Words for .NET 14.10.0 and have not found the shared issue. I suggest you please use Aspose.Words for .NET 14.10.0 and let us know how it goes on your side.

Please let us know if you have any more queries.

Hi,


I updated to the latest version and the error doesn’t appear any more. Thank you!

Hi Veselin,

Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.