Source difference between Syncfusion.SfInput.WPF 19.4.0.56 and 20.1.0.48

Hi,

After upgrading my project dependencies from 19.4.0.56 to 20.1.0.48, I am getting this error that totally crashes my application.

Message: Object reference not set to an instance of an object.

Source: "Syncfusion.SfInput.Wpf"

   at Syncfusion.Windows.Controls.Input.SuggestionBox.Listboxitem_Loaded(Object sender, RoutedEventArgs e)

   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)

   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)

   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()

   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()

   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)

   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)

   at System.Windows.Media.MediaContext.Resize(ICompositionTarget resizedCompositionTarget)

   at System.Windows.Interop.HwndTarget.OnResize()

   at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)

   at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)


It can be triggered when I simply click in the field and it appears as if the SfTextBoxExt  autocompletesource is not initialized, which causes the crash. The timing of the crash varies, which makes it difficult for me to understand.

Below a snippet of what I defined in xaml and works fine with 19.4.0.56.

 <sf:SfTextInputLayout

                x:Name="PrescriptionMedTIL"

Grid.Column="0"

                Hint="Product"

                HelperText="Selecteer een artikel">


                    <sf:SfTextBoxExt x:Name="ProductNameTBControl"

                                     SearchItemPath="ProductName"

                                     AutoCompleteMode="Suggest"

                                     AutoCompleteSource="{Binding MedicationDBItemsSource}"

                                     SelectedItem="{Binding SelectedMed, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

                                     Text="{Binding ProductNameTB, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"

                                     SuggestionMode="ContainsOrdinal"

                                     HighlightedTextColor="#FFD65532"

                                     TextHighlightMode="MultipleOccurrence"

                                     IsEnabled="{Binding AllowChanges, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">

                    </sf:SfTextBoxExt>

                </sf:SfTextInputLayout>

Please let me know if you have any thoughts on this.


Kind regards,


Niels van Strien


5 Replies

NV NM van Strien April 12, 2022 06:00 PM UTC

I have to retract my statement. It does also happen in 19.4.0.56.


So probably it is something I am doing wrong - but I can't seem to understand what it is.



NV NM van Strien April 13, 2022 07:33 AM UTC

Hi again,


The problem seems to be caused by a delay in getting access to the AutoCompleteSource.

Perhaps it is a performance issue due to the fact that I connected a lot of data to the AutoCompleteSource.

It seems to me that when the AutoCompleteSource  is initialized, the error is thrown. Less than a second later the AutoCompleteSource is available and can be used normally. 

The referred MedicationDBItemsSource contains 2000 objects and only the SearchItemPath="ProductName" is used of course. Should I have done this differently when so many objects are in the AutoCompleteSource ?

I am now catching the exception in an application wide App_DispatcherUnhandledException method like this


if (e.Exception.HResult.Equals(-2147467261)) && e.Exception.Source == "Syncfusion.SfInput.Wpf")

{

                // Prevent default unhandled exception processing, i.e. closing application;

                e.Handled = true;

}


This prevents the application to shut down and the user doesn't notice the error is thrown. After the exception is handled in this way, the exception doesn't affect the interaction with the control anymore. The AutoCompleteSource is available and ready for interaction.


I don't like the way I handle this here, but for now it is a workaround. Perhaps you have some advice on how to proceed.


K



RS Ruba Shanmugam Syncfusion Team April 15, 2022 12:03 PM UTC

Hi NM van Strien,


We have fixed the reported issue “[WPF] Null reference issue”. Please find the patch assemblies from the attachment.


Note: Please refer to the below link to apply the custom assembly 


https://www.syncfusion.com/kb/8279/how-to-apply-the-custom-assemblies-when-configured-the-project-with-syncfusion-nuget


This fix will be included in our weekly NuGet release which will be rolled out on April 19, 2022. We appreciate your patience until then.

Regards,

Ruba Shanmugam


Attachment: Patch_62f21fb8.zip


NV NM van Strien April 21, 2022 07:06 AM UTC

Thank you Ruba.


I have installed the latest nuget update and have not seen the error return. I have not yet tested extensively, but assume that it has been fixed as you indicated.


Kind regards,


Niels van Strien



RS Ruba Shanmugam Syncfusion Team April 22, 2022 06:02 AM UTC

Hi Niels,


Thanks for the update. Please let us know if you have any concerns.


Regards,

Ruba Shanmugam


Loader.
Up arrow icon