MvvmBlazor icon indicating copy to clipboard operation
MvvmBlazor copied to clipboard

Index out of bound exception

Open HarshitPradhan opened this issue 10 months ago • 0 comments

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, Action2 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

HarshitPradhan avatar Sep 12 '23 10:09 HarshitPradhan