We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Compare DOC Files using C# .NET Code | Avoid System.InvalidCastException

Hi,

we get an InvalidCastException when comparing two documents.
Additional information (roughly translated):

Object of type “Aspose.Words.Tables.Table” cannot be converted to “Aspose.Words.Paragraph”.

Test code:

            var oldDocument = new Document(@"S:\tmp\revcompare\old.doc");
            var newDocument = new Document(@"S:\tmp\revcompare\new.doc");

            oldDocument.Compare(newDocument, "author", DateTime.UtcNow);

Documents are attached. Thanks for your help.
documents.zip (39.1 KB)

@Serraniel,

You are right; the current version of Aspose.Words for .NET throws following exception upon comparing these particular Word DOC files:

System.InvalidCastException
HResult=0x80004002
Message=Unable to cast object of type 'Aspose.Words.Tables.Table' to type 'Aspose.Words.Paragraph'.
Source=Aspose.Words

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

The issues you have found earlier (filed as WORDSNET-22668) have been fixed in this Aspose.Words for .NET 21.9 update.