[ERROR] An item with the same key has already been added.
The code works perfectly, but at strange moments for me there is an error "ArgumentException: An item with the same key has already been added";
The code is very simple, there are 2 ListBox. Each of them is bound to its own ObservableCollection<BaseResearchItem>.
When I double click on ContentControl it moves BaseResearchItem from one ObservableCollection to another ObservableCollection. Everything works without errors, I can move dozens, hundreds of times from one collection to another, But sometimes this error appears.
And Yes, there is no Dictionary in my code.
More error information.
BaseResearchItem contains the following properties.
BaseItem.get_Icon () (at Assets/Scripts/BaseItem/BaseItem.cs:64)
at Assets/GUI/ScienceWindowViewModel.cs:87
Before the mistake.
After an error.
The code is very simple, there are 2 ListBox. Each of them is bound to its own ObservableCollection<BaseResearchItem>.
When I double click on ContentControl it moves BaseResearchItem from one ObservableCollection to another ObservableCollection. Everything works without errors, I can move dozens, hundreds of times from one collection to another, But sometimes this error appears.
And Yes, there is no Dictionary in my code.
More error information.
Code: Select all
ArgumentException: An item with the same key has already been added. Key: 2489215921760
System.Collections.Generic.Dictionary`2[TKey,TValue].TryInsert (TKey key, TValue value, System.Collections.Generic.InsertionBehavior behavior) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.Collections.Generic.Dictionary`2[TKey,TValue].Add (TKey key, TValue value) (at <23c160f925be47d7a4fd083a3a62c920>:0)
Noesis.Texture.WrapTexture (System.Object texture, System.IntPtr nativePointer, System.Int32 width, System.Int32 height, System.Int32 numLevels) (at Assets/NoesisGUI/Plugins/NoesisTexture.cs:21)
Noesis.TextureSource..ctor (UnityEngine.Texture2D texture) (at Assets/NoesisGUI/Plugins/NoesisTextureSource.cs:12)
Texture2DExtension.EncodeToNoesisImage (UnityEngine.Texture2D texture) (at Assets/Scripts/Extension/Texture2DExtension.cs:9)
BaseItem.get_Icon () (at Assets/Scripts/BaseItem/BaseItem.cs:64)
System.Reflection.MonoProperty.GetterAdapterFrame[T,R] (System.Reflection.MonoProperty+Getter`2[T,R] getter, System.Object obj) (at <23c160f925be47d7a4fd083a3a62c920>:0)
System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) (at <23c160f925be47d7a4fd083a3a62c920>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoProperty.GetValue (System.Object obj, System.Object[] index) (at <23c160f925be47d7a4fd083a3a62c920>:0)
Noesis.Extend+PropertyAccessorPropRO`1+<>c__DisplayClass1_0[PropertyT].<.ctor>b__0 (System.Object instance) (at Assets/NoesisGUI/Plugins/API/Core/ExtendProps.cs:125)
Noesis.Extend+PropertyAccessorPropRO`1[PropertyT].Get (System.Object instance) (at Assets/NoesisGUI/Plugins/API/Core/ExtendProps.cs:130)
Noesis.Extend.GetPropertyValue[T] (Noesis.Extend+PropertyAccessor prop, System.Object instance) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:2976)
Noesis.Extend.GetPropertyValue_BaseComponent (System.IntPtr nativeType, System.Int32 propertyIndex, System.IntPtr cPtr) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:3387)
UnityEngine.Debug:LogException(Exception)
NoesisUnity:OnUnhandledException(Exception) (at Assets/NoesisGUI/Plugins/NoesisUnity.cs:142)
Noesis.Error:UnhandledException(Exception) (at Assets/NoesisGUI/Plugins/API/Core/Error.cs:18)
Noesis.Extend:GetPropertyValue_BaseComponent(IntPtr, Int32, IntPtr) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:3392)
Noesis.Extend:Noesis_LaunchPropertyChangedEvent(IntPtr, IntPtr, String)
Noesis.Extend:NotifyPropertyChanged(Object, PropertyChangedEventArgs) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:4403)
GUI_Blend.NotifyPropertyChangedBase:OnPropertyChanged(String) (at Assets/GUI/Extension/NotifyPropertyChangedBase.cs:14)
GUI_Blend.ScienceWindowViewModel:set_SelectedResearchItem(BaseResearchItem) (at Assets/GUI/ScienceWindowViewModel.cs:87)
System.Reflection.PropertyInfo:SetValue(Object, Object, Object[])
Noesis.<>c__DisplayClass2_0:<.ctor>b__1(Object, Object) (at Assets/NoesisGUI/Plugins/API/Core/ExtendProps.cs:106)
Noesis.PropertyAccessorPropRW`1:Set(Object, Object) (at Assets/NoesisGUI/Plugins/API/Core/ExtendProps.cs:116)
Noesis.Extend:SetPropertyValue(PropertyAccessor, Object, Object) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:3402)
Noesis.Extend:SetPropertyValue_BaseComponent(IntPtr, Int32, IntPtr, IntPtr, IntPtr) (at Assets/NoesisGUI/Plugins/API/Core/Extend.cs:3809)
Noesis.View:Noesis_View_MouseButtonDown(HandleRef, Int32, Int32, Int32)
Noesis.View:MouseButtonDown(Int32, Int32, MouseButton) (at Assets/NoesisGUI/Plugins/API/Core/View.cs:126)
NoesisView:ProcessEvent(Event, Boolean, Boolean, Boolean) (at Assets/NoesisGUI/Plugins/NoesisView.cs:936)
NoesisView:OnGUI() (at Assets/NoesisGUI/Plugins/NoesisView.cs:1045)
Code: Select all
public string Name
public string Description
public Noesis.TextureSource Icon
Code: Select all
62 [SerializeField]
63 private Texture2D _icon = null;
64 public Noesis.TextureSource Icon { get { return _icon.EncodeToNoesisImage(); } }
public static Noesis.TextureSource EncodeToNoesisImage(this Texture2D texture)
{
return new Noesis.TextureSource(texture);
}
Code: Select all
77 private BaseResearchItem _selectedResearchItem;
78 public BaseResearchItem SelectedResearchItem
79 {
80 get
81 {
82 return _selectedResearchItem;
83 }
84 set
85 {
86 _selectedResearchItem = value;
87 OnPropertyChanged("SelectedResearchItem");
88 }
90 }
After an error.
Re: [ERROR] An item with the same key has already been added.
Found in a bag tracker, already decided, I will wait for a new version. The topic can be closed or deleted.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: [ERROR] An item with the same key has already been added.
Yes, this seems the same bug as the one described here: #1607.
It will appear fixed in the next release, thanks for reporting anyway.
It will appear fixed in the next release, thanks for reporting anyway.
Who is online
Users browsing this forum: Ahrefs [Bot] and 26 guests