I am seeing several threads all related to this (document.UpdatePageLayout(), UpdateFields(), etc as well as saving as PDF). A System.NullReferenceException is getting thrown and I believe it is related to SkiaSharp. These methods are good in .Net Framework but throw the error using .Net Core.
Message: “Object reference not set to an instance of an object.”
StackTrace: " at \u000f .\b(SKBitmap \u0002)"
TargetSite: Boolean (SkiaSharp.SKBitmap)
@netappcole,
Please ZIP and attach the following resources here for testing:
- Your simplified source Word document
- A standalone simple Console application (source code without compilation errors) that helps us to reproduce this exception on our end and attach it here for testing. Please do not include Aspose.Words DLL files in it to reduce the file size.
As soon as you get these pieces of information ready, we will start investigation into your scenario and provide you more information.
Hi Awais,
I have attached the solution zip.
If I remove the .bmp image the UpdatePageLayout() method does not throw an error. Also, if I open this doc in Word and save it, subsequently calling UpdatePageLayout() does not throw an error. I have not passed along the .lic file.
AsposeTest.zip (226 KB)
@slt_netapp,
After an initial test with the licensed latest (21.3) version of Aspose.Words for .NET, I was unable to reproduce this exception on my end. Please see the following output PDF file which was generated on my end:
Code used to produce above PDF file is as follows:
Aspose.Words.License lic = new Aspose.Words.License();
lic.SetLicense("Aspose.Words.lic");
Document doc = new Document("test.docx");
doc.UpdatePageLayout();
doc.Save("21.3.pdf");
Please make sure that you had provided the correct unmodified test.docx document that you are actually getting this problem with. I tested the scenario on Windows 10 machine using Visual Studio 2017 and .NET Core 3.0. Can you please also share your development environment details? Do you see this exception on any other machine on your end?