NullReferenceException in PdfViewerControl when setting Window SizeToContent to Width/Height

I am encountering a NullReferenceException when setting the SizeToContentproperty on the window that hosts the PdfViewerControlto either Width or Height

The exception message is as follows:

System.NullReferenceException: 'Object reference not set to an instance of an object.'

After the exception, visual Studio automatically decompiled the source code and pointed to the following line where the exception occurs:

// DocumentToolbar.cs
elseif(m_activeView.CursorMode==PdfViewerCursorMode.HandTool&& m_buttonPan !=null)//m_activeView is null
{
m_selectToolToggleButton.IsChecked=false; m_buttonPan.IsChecked=true; m_buttonPan.IsHitTestVisible=false;
}

SyncfusionPdfViewer.WPF version: 27.1.50
Attachment: SampleAppCore_7d82b012.zip

3 Replies 1 reply marked as answer

YM Yathavakrishnan Mohan Syncfusion Team December 24, 2024 08:23 AM UTC

We were able to reproduce the reported issue with the provided details on our end, and currently we are analyzing it. We will provide further details on December 27th, 2024



KG Krithika Ganesan Syncfusion Team December 27, 2024 02:47 PM UTC

We have confirmed the issue "`NullReferenceException` occurs when SizeToContentproperty of window is set to either Width or Height" as a defect in our product and we will include the fix into our upcoming weekly NuGet release which will we available on 7th January 2025.

 

Please use the below feedback link to track the status of the reported bug.

https://www.syncfusion.com/feedback/64340/nullreferenceexception-occurs-when-sizetocontentproperty-of-window-is-set-to

Note: If you require a patch for the reported issue in any of our Essential Studio Main or SP release version, then kindly let us know the version, so that we can provide a patch in that version based on our SLA policy.

 

Disclaimer: “Inclusion of this solution in the weekly release may change due to other factors including but not limited to QA checks and works reprioritization.”



YM Yathavakrishnan Mohan Syncfusion Team January 7, 2025 11:56 AM UTC

We have included the fix for this “`NullReferenceException` occurs when SizeToContentproperty of window is set to either Width or Height” in our latest weekly release (28.1.38). Upgrade to the latest version, to get the issue resolved.
Root Cause:
PdfDocumentView was not initialized in DocumentToolbar OnApplyTemplate when SizeToContentproperty of window is set to either Width or Height.

 
Please use the below link to download our latest NuGet,
Nuget Link:
Feedback link

Marked as answer
Loader.
Up arrow icon