Json Assets 'collection was modified' error
Pathoschild opened this issue ยท 3 comments
Json Assets adds an asset editor in the Specialised.LoadStageChanged
event since 1.3.1. Some players report a 'collection was modified' error when that code is run (see Nexus comments for Json Assets):
[Json Assets] This mod failed in the Specialised.LoadStageChanged event. Technical details:
System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
at System.Collections.Generic.List`1.Enumerator.MoveNext()
at StardewModdingAPI.Framework.ContentCoordinator.InvalidateCache(Func`3 predicate, Boolean dispose) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\ContentCoordinator.cs:line 242
at StardewModdingAPI.Framework.ContentCoordinator.InvalidateCache(Func`2 predicate, Boolean dispose) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\ContentCoordinator.cs:line 227
at StardewModdingAPI.Framework.ContentCoordinator.InvalidateCacheFor(IAssetEditor[] editors, IAssetLoader[] loaders) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\ContentCoordinator.cs:line 183
at StardewModdingAPI.Framework.SCore.<>c__DisplayClass33_0.<LoadMods>b__7(Object sender, NotifyCollectionChangedEventArgs e) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\SCore.cs:line 862
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.InsertItem(Int32 index, T item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at JsonAssets.Mod.onSaveLoaded() in G:\StardewValley\Mods\JsonAssets\Mod.cs:line 496
at JsonAssets.Mod.onLoadStageChanged(Object sender, LoadStageChangedEventArgs e) in G:\StardewValley\Mods\JsonAssets\Mod.cs:line 339
at StardewModdingAPI.Framework.Events.ManagedEvent`1.Raise(TEventArgs args) in C:\source\_Stardew\SMAPI\src\SMAPI\Framework\Events\ManagedEvent.cs:line 62
I haven't seen this error in a while, so it seems to have been fixed in one of the SMAPI or Json Assets releases.
[Json Assets] Failed in CanBeGivenAsGift_Postfix for #336 Gold Bar:
System.NullReferenceException: Object reference not set to an instance of an object.
at JsonAssets.Overrides.ObjectPatches.CanBeGivenAsGift_Postfix(Object __instance, Boolean& __result) in G:\StardewValley\Mods_1.4\JsonAssets\Overrides\ObjectPatches.cs:line 197
I have a log full of this after updating my json assets today. I noticed it when I went to Sandy to buy something. There were a bunch of "error item"(s) in her inventory. I checked in Pierre's store, same there. I'm not sure what to do now. Please advise. Thanks in advance! ( can provide full log if needed )
Sel
That seems like a bug in Json Assets, and unrelated to this ticket. I suggest reporting it on the Json Assets page instead.