{"record":{"id":"48bd3710541a9a66","repo":"egametang/ET","slug":"serialization-invalidondeser","errorCode":null,"errorMessage":"Serialization_InvalidOnDeser","messagePattern":"Serialization_InvalidOnDeser","errorType":"exception","errorClass":"SerializationException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs","lineNumber":1711,"sourceCode":"            {\n                T[] items = new T[Count];\n                CopyTo(items, 0);\n                info.AddValue(ItemsName, items, typeof(T[]));\n            }\n        }\n\n        void IDeserializationCallback.OnDeserialization(object sender) => OnDeserialization(sender);\n\n        protected virtual void OnDeserialization(object sender)\n        {\n            if (comparer != null)\n            {\n                return; // Somebody had a dependency on this class and fixed us up before the ObjectManager got to it.\n            }\n\n            if (siInfo == null)\n            {\n                throw new SerializationException(SR.Serialization_InvalidOnDeser);\n            }\n\n            comparer = (IComparer<T>)siInfo.GetValue(ComparerName, typeof(IComparer<T>))!;\n            int savedCount = siInfo.GetInt32(CountName);\n\n            if (savedCount != 0)\n            {\n                T[] items = (T[])siInfo.GetValue(ItemsName, typeof(T[]));\n\n                if (items == null)\n                {\n                    throw new SerializationException(SR.Serialization_MissingValues);\n                }\n\n                for (int i = 0; i < items.Length; i++)\n                {\n                    Add(items[i]);\n                }","sourceCodeStart":1693,"sourceCodeEnd":1729,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs#L1693-L1729","documentation":"Thrown by SortedSet<T>.OnDeserialization when comparer is still null AND siInfo (the stored SerializationInfo) is null. This means the deserialization callback fired on an instance that was never serialized through GetObjectData, so there is no data to rebuild from. It surfaces as a SerializationException.","triggerScenarios":"Manually invoking IDeserializationCallback.OnDeserialization on a SortedSet that was not serialized; registering a SortedSet with a formatter that skipped GetObjectData; deserializing a graph where another object already fixed up the set but no SerializationInfo was ever attached.","commonSituations":"Mixing BinaryFormatter/NetDataContractSerializer flows; custom serialization surrogates that omit the SortedSet entry; triggering OnDeserialization twice after the first call already nulled siInfo; porting code to a runtime where serialization hooks behave differently.","solutions":["Ensure the set is serialized with the same formatter that raises OnDeserialization, so SerializationInfo is populated.","Do not call OnDeserialization manually; let the ObjectManager drive it.","If you use a surrogate/selector, make sure it writes all SortedSet keys (ComparerName, CountName, ItemsName)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Avoid manual OnDeserialization; only deserialize sets written by the same formatter.\n// If you must call it, guard for the missing-info case:\nif (set is IDeserializationCallback cb) {\n    // do not invoke manually; let the ObjectManager raise it\n}","typeGuard":null,"tryCatchPattern":"try { /* deserialize graph */ } catch (SerializationException ex) when (ex.Message.Contains(\"Serialization_InvalidOnDeser\")) { /* log and rebuild set from alternate source */ }","preventionTips":["Never call IDeserializationCallback.OnDeserialization by hand.","Keep serialize/deserialize code versions in sync.","Prefer modern serializers over BinaryFormatter for SortedSet."],"tags":["sortedset","serialization","deserialization","csharp"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}