Aspose.Words.FileCorruptedException is thrown while importing Document using .NET

Hello,

We have a software that’s running Aspose.Words 9.6, we’re facing an issue with new docx files
content = File.ReadAllBytes(“path”);
MemoryStream ms = new MemoryStream(content);
MemoryStream msout = new MemoryStream();
Aspose.Words.Document doc = new Aspose.Words.Document(ms); // <- exception here
ms.Close();
doc.Save(msout, Aspose.Words.SaveFormat.Docx);
content = msout.ToArray();
msout.Close();

The exception
Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded. —> System.NullReferenceException: La référence d’objet n’est pas définie à une instance d’un objet.
à xda075892eccab2ad.xc1b08afa36bf580c.xa9aaee2edd3cd025(String x971e83bc97861294, Byte[] xf9a0d04800d70471, Int32 x10aaa7cdfa38f254)
à x79490184cecf12a1.xc37fee571c29ba92.xdafccb198ba91439(x3c85359e1389ad43 x97bf2eeabd4abc7b)
à x79490184cecf12a1.xc37fee571c29ba92.x2506b757d67702ec(x3c85359e1389ad43 x97bf2eeabd4abc7b)
à x79490184cecf12a1.xc37fee571c29ba92.x902b6f807c71becd(x3c85359e1389ad43 x97bf2eeabd4abc7b, x3dabda6865ed239d x8ad4cdceb54e447f)
à x79490184cecf12a1.xc37fee571c29ba92.xd4c5b858945b0ab2(x3c85359e1389ad43 x97bf2eeabd4abc7b, x3dabda6865ed239d x8ad4cdceb54e447f)
à x79490184cecf12a1.xc37fee571c29ba92.x06b0e25aa6ad68a9(xa52ef41af20225f0 xe134235b3526fa75)
à x79490184cecf12a1.xa52ef41af20225f0.DoRead()
à x79490184cecf12a1.x11e1346c12ead315.x06b0e25aa6ad68a9()
à x79490184cecf12a1.xae13d15563a3a703.x748a2047fcb706ad()
à x79490184cecf12a1.xae13d15563a3a703.x06b0e25aa6ad68a9()
à Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
— Fin de la trace de la pile d’exception interne —
à Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
à Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
à Aspose.Words.Document…ctor(Stream stream, LoadOptions loadOptions)
à Aspose.Words.Document…ctor(Stream stream)
à CEGC.AppPI.Client.Infrastructure.Interface.Technical.DocumentAccess.OpenFile(Byte[] content, String fileExtension, Guid docId, Boolean openReadonly)
à CEGC.AppPI.Client.Infrastructure.Interface.Technical.DocumentAccess.OpenFile(Byte[] content, String fileExtension, Boolean openReadonly)
à CEGC.AppPI.Client.ModuleManagement.ManageDocType.GetDocData(DocumentType doc)
à CEGC.AppPI.Client.ModuleManagement.ManageDocType.dgvDocType_CellContentClick(Object sender, DataGridViewCellEventArgs e)
à System.Windows.Forms.DataGridViewCell.OnMouseUpInternal(DataGridViewCellMouseEventArgs e)
à System.Windows.Forms.DataGridView.OnCellMouseUp(DataGridViewCellMouseEventArgs e)
à System.Windows.Forms.DataGridView.OnMouseUp(MouseEventArgs e)
à System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
à System.Windows.Forms.Control.WndProc(Message& m)
à System.Windows.Forms.DataGridView.WndProc(Message& m)
à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
à System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
à System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
à System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
à Microsoft.Practices.CompositeUI.WinForms.FormShellApplication2.Start() à Microsoft.Practices.CompositeUI.CabApplication1.Run()
à SOME.SOFTWARE.Main(String[] args) dans

Can you please tell me how to fix this ?

Thank you

@fzitouni

You are using very old version of Aspose.Words. We suggest you please upgrade to the latest version of Aspose.Words for .NET 21.1. Hope this helps you.

If you still face problem, please ZIP and attach your input Word document here for testing. We will investigate the issue and provide you more information on it.