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

Free Support Forum - aspose.com

Document.PageCount throws NullReferenceException

Hi.

I have a problem with particular document in the attachment section. When I’m trying to run the code like this:

const string file = “input.docx”;
var document = new Document(file);
Console.WriteLine(document.PageCount);
I get this error:
System.NullReferenceException: Object reference not set to an instance of an obj
ect.
at :heart:? .:slight_smile:(:spades: ? :slight_smile:, ♫ :heart:, ♫ :clubs:)
at :heart:? .:slight_smile:(:spades: ? :slight_smile:, Single :heart:, Single :clubs:)
at :heart:? .:spades:()
at :clubs:? .☼ ()
at :clubs:? .:clubs:? ?♫ (Boolean :slight_smile:)
at :spades:? .:clubs:(:clubs:? :slight_smile:)
at :spades:? .:heart:(:clubs:? :slight_smile:, Boolean :heart:)
at :spades:? .:slight_smile:(:clubs:? :slight_smile:)
at :clubs:? (♫? :slight_smile:)
at :clubs:? .:heart:(♫? :slight_smile:)
at ☼? .☼()
at ☼? .♫()
at :slight_smile:? .:slight_smile:(♫? :slight_smile:)
at :heart:? .:slight_smile:(♫? :slight_smile:)
at :heart:? .:slight_smile:(♫? :slight_smile:, Int32 :heart:)
at .:slight_smile:(:clubs: :slight_smile:, Int32 :heart:, Boolean :clubs:)
at :slight_smile:? .:clubs:()
at :slight_smile:? .:slight_smile:(:spades:? :slight_smile:, Int32 :heart:, Boolean :clubs:, Boolean)
at :slight_smile: ()
at :slight_smile: .:slight_smile:(☼ :slight_smile:, Int32 :heart:)
at .:slight_smile:(☼ :slight_smile:)
at .:slight_smile:()
at .:slight_smile:(:clubs: :slight_smile:)
at :spades: .:slight_smile:(Boolean :slight_smile:)
at :spades: .:slight_smile: ()
at ♫? .:slight_smile:(Document :slight_smile:, :heart:? :heart:)
at Aspose.Words.Document.UpdatePageLayout()
at Aspose.Words.Document.get_PageCount()
I’m using Aspose.Words for .NET 15.12
Hi Artem,

Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 16.2.0 and have not found the shared issue. Please use Aspose.Words for .NET 16.2.0 and let us know if you have any more queries.