App crashes when I start typing in the SfAutoComplete element

Hi,
I'm using the SfAutoComplete control to select a CultureInfo. 
This is my XAML code.

<autocomplete:SfAutoComplete 
                                    DataSource="{Binding Cultures}" AutoCompleteMode="SuggestAppend"
                                    SelectedItem="{Binding SelectedCulture, Mode=TwoWay}"
                                    MultiSelectMode="None"
                                    DisplayMemberPath="DisplayName" 
                                    SuggestionMode="Contains"
                                    Margin="16,2,16,4"
                                    Grid.Row="1" Grid.ColumnSpan="3"
                                    >
                            </autocomplete:SfAutoComplete>

Code behind:

private CultureInfo _selectedCulture = LocalizationManager.GetInstance().Culture;
        public CultureInfo SelectedCulture
        {
            get => _selectedCulture;
            set
            {
                if (value == _selectedCulture)
                    return;

                _selectedCulture = value;
                if (_selectedCulture != null)
                {
                    CurrencySymbol = _selectedCulture.NumberFormat.CurrencySymbol;
                    OverwriteCultureCode = SelectedCulture.Name;
                    if(!_isLoading)
                        RestartRequired = true;
                }
                OnPropertyChanged();
            }
        }

private ObservableCollection<CultureInfo> _cultures = new ObservableCollection<CultureInfo>();
        public ObservableCollection<CultureInfo> Cultures
        {
            get => _cultures;
            set
            {
                if (_cultures == value) return;
                _cultures = value;
                OnPropertyChanged();
            }
        }

In the constructor of my page I'll set the Cultures property like this.

Cultures = new ObservableCollection<CultureInfo>(CultureInfo.GetCultures(CultureTypes.AllCultures).Where(c => !c.IsNeutralCulture && !string.IsNullOrEmpty(c.DisplayName)).ToList());

By default I set the SelectedCulture to the current device culture. This is working fine. The selected item appears in set in the SfAutoComplete control.
If I click the "clear" button and start typing, the app crashes with this exception.

{System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object  at System.Globalization.CultureInfo.get_NativeCalendarName () [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Globalization/CultureInfo.cs:301   at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395    --- End of inner exception stack trace ---  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00081] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:409   at System.Reflection.RuntimePropertyInfo.GetValue (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] index, System.Globalization.CultureInfo culture) [0x00038] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimePropertyInfo.cs:442   at System.Reflection.RuntimePropertyInfo.GetValue (System.Object obj, System.Object[] index) [0x00006] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimePropertyInfo.cs:429   at System.Reflection.PropertyInfo.GetValue (System.Object obj) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/external/corefx/src/Common/src/CoreLib/System/Reflection/PropertyInfo.cs:43   at Syncfusion.SfAutoComplete.iOS.SfAutoComplete.ConvertingToNsObject (System.Object item) [0x00114] in <eb2fac1a376a405296ff43e05a9cba63>:0   at Syncfusion.SfAutoComplete.iOS.AutoCompeteTableSource.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00f43] in <eb2fac1a376a405296ff43e05a9cba63>:0   at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)  at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:86   at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Library/Frameworks/Xamarin.iOS.framework/Versions/13.18.2.1/src/Xamarin.iOS/UIKit/UIApplication.cs:65   at PrintCostCalculator3d.iOS.Application.Main (System.String[] args) [0x00001] in C:\3DPCC\3dPrintCostCalculator\3dPrintCostCalculator\RemoteControlOctoPrint.iOS\Main.cs:17 }



1 Reply

SP Sakthivel Palaniyappan Syncfusion Team July 27, 2020 09:32 AM UTC

Hi Andreas,

Greetings from Syncfusion.

We have prepared a sample with our understanding and we have checked the issue in SfAutoComplete with NuGet Package (18.2.0.46) and we are unable to reproduce the issue from our end. Please check with the sample with which we have ensured,

Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/AutoComplete_156354-1424203904

Please check with the above sample and if still exists,

 * Please modify the above sample with the issue reproducing steps,
 * Provide additional details of the issue and also provide video representation of the issue if possible since we are unaware of the exact application scenario.

The above will help us identify the problem and provide the solution at the earliest possible.

Regards,
Sakthivel P.



Loader.
Up arrow icon