MvvmBlazor
MvvmBlazor copied to clipboard
Index out of bound exception
Bug description
While working on my application it's a once in a lifetime scenario that I've encountered this exception and I'm unable to figure it out why this error came and how to fix this error.
This is the message that I have received
RefreshCountingFromThread Thread Exception : Index was outside the bounds of the array.: at System.Collections.Generic.Dictionary2.TryInsert(TKey key, TValue value, InsertionBehavior behavior) at MvvmBlazor.Internal.WeakEventListener.WeakEventManager.AddWeakEventListener[T](T source, Action
2 handler)
at MvvmBlazor.Internal.Bindings.Binding.AddCollectionBindings()
at MvvmBlazor.Internal.Bindings.Binding.SourceOnPropertyChanged(Object sender, PropertyChangedEventArgs e)
at MvvmBlazor.Internal.WeakEventListener.WeakEventListenerBase`2.HandleEvent(Object sender, TArgs e)
at MvvmBlazor.ViewModel.ViewModelBase.OnPropertyChanged(String propertyName)
at MvvmBlazor.ViewModel.ViewModelBase.Set[T](T& field, T value, String propertyName)
at <ViewModel_Full_Path>.UpdateDetailView()
Expectation
How to not get this exception again as the application is used by many clients and the application is deployed in the field already.
Code sample
public ObservableCollection<DetailDataDTO> DetailsData
{
get { return detailsData; }
set { Set(ref detailsData, value); }
}
private ObservableCollection<DetailDataDTO> detailsData;
private void UpdateDetailView()
{
...
...
...
this.DetailsData = this.DataInventory.GetDetailsData();
...
...
...
}
Version
2.0.0
Are you using Blazor WASM or Blazor Server?
Blazor Server
What operation system are you working with?
Linux