Free Support Forum - aspose.com

Avoid File Corrupted & Null Reference Exceptions on Loading Opening MS Word DOC Document with Aspose.Words for .NET C#

Hi,
I am trying to load the attached doc file with Aspose.Words .NET 21.2 but there is an exception with the message The document appears to be corrupted and cannot be loaded. while the file is opened successfully. Can you review the sample and give me advice?
Code:
try
{
var doc = new Document(@“sample.doc”);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
Console.WriteLine(“Done”);

Thanks.sample.zip (44.5 KB)

@dunghnguyen,

You’re right; Aspose.Words for .NET currently throws following exception upon loading this particular Word DOC document that you shared:

Aspose.Words.FileCorruptedException
HResult=0x80131500
Message=The document appears to be corrupted and cannot be loaded.
Source=Aspose.Words
Inner Exception 1:
NullReferenceException: Object reference not set to an instance of an object.

For the sake of correction, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-21870. We will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.