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

Free Support Forum - aspose.com

Aspose.Words.Documents.PageCount: 'document.PageCount' threw an exception of type 'System.NullReferenceException'

I am reading a document from local drive by:
Dim document As Aspose.Words.Document = New Aspose.Words.Document(sFileName)
But when reading that I have bug when calling document.PageCount:
'document.PageCount' threw an exception of type 'System.NullReferenceException'
By changing the content of the document so that the amount of paragraphes changes, the bug is gone. But I want to know why I have the bug in this document by this content.

@stanlife,

Thanks for your inquiry. Please ZIP and attach your input Word document here for testing. We will investigate the issue on our side and provide you more information.

@stanlife,

Thanks for sharing the document. We have tested the scenario using latest version of Aspose.Words for .NET 18.5 and have not found the shared issue. Please use Aspose.Words for .NET 18.5.

Is it possible for you to test it with version 17.1.0. Upgrading to 18.5 will result in a lot of regression tests and big changes in our code. We would like to fix the problem or circumvent it if possible without going into regression tests and big code changes. Maybe it is a small bug which can be fixed on our side.

Any progress?

@stanlife,

Thanks for your inquiry. Please note that we do not provide support for older released versions of Aspose.Words. Moreover, we do not provide any fixes or patches for old versions of Aspose products either. All fixes and new features are always added into new versions of our products.

We always encourage our customers to use the latest version of Aspose.Words as it contains newly introduced features, enhancements and fixes to the issues that were reported earlier.

We have not found this issue while using Aspose.Words 17.1. Please make sure that you have attached the correct document for which you are facing the issue.

I have built a very simple solution with seven lines of code which you can run and see the bug. The bug in Aspose raises because we use Hyphenation Dictionary. If I don’t use it the problem does not raise.
The solution is attached to this post. Just insert your Aspose.Words.dll in the bin folder. I had to delete it because otherwise I was not able to upload the solution here due to your max size limitation.

@stanlife,

Thanks for your inquiry. We have not found the shared issue while using latest version of Aspose.Words for .NET 18.5. Please upgrade to Aspose.Words for .NET 18.5.

Hello, I have changed the solution. In the previous one I wasn’t calling Document.PageCount and this is perhaps the reason you haven’t the bug on your side. Could you test the new solution I attached to this message

@stanlife,

Thanks for your inquiry. We have tested the scenario using shared application and have not faced any exception. Please check the attached screenshot. output.png (31.9 KB)

Please upgrade to the latest version of Aspose.Words for .NET 18.5.