{"record":{"id":"d15ba9fe7b0dc2be","repo":"stride3d/stride","slug":"no-serializer-available-for-type","errorCode":null,"errorMessage":"No serializer available for type ","messagePattern":"No serializer available for type ","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core/Serialization/MemberSerializerCore.ttinclude","lineNumber":30,"sourceCode":"<# if (supportsReuseReferences || supportsNonSealed || supportsNullDataSerializer) { #>\n        var context = stream.Context;\n<# } #>\n\n<# if (supportsValueType) { #>\n<# if (supportsGenerics) { #>\n        if (isValueType)\n<# } else { #>\n        if (objType.IsValueType)\n<# } #>\n        {\n<# if (supportsNullDataSerializer) { #>\n            if (dataSerializer is null)\n            {\n                dataSerializer = <#= serializerCastExpr #>context.SerializerSelector.GetSerializer(<#= typeExpr #>);\n\n                // If we still have no serializer, throw an exception\n                if (dataSerializer is null)\n                    throw new ArgumentException(\"No serializer available for type \" + <#= typeExpr #>.FullName);\n            }\n<# } // supportsNullDataSerializer #>\n\n            // Structure, no need to check for inheritance or null values.\n            dataSerializer.Serialize(ref obj, mode, stream);\n\n            return;\n        }\n\n<# } #>\n\n<# if (supportsNonSealed || supportsReuseReferences) { #>\n        // Serialize either with dataSerializer if obj is really of type T, otherwise look for appropriate serializer.\n        SerializeClassFlags flags;\n<# } #>\n<# if (supportsReuseReferences) { #>\n        bool reuseReferences = context.SerializerSelector.ReuseReferences;\n        int index;","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core/Serialization/MemberSerializerCore.ttinclude#L12-L48","documentation":"During member serialization of a struct/value type, the serializer selector returned null even after a lookup, meaning no DataSerializer is registered for the type's FullName. Stride's serialization is registry-based: types must have generated or custom serializers to cross the stream, so it throws ArgumentException rather than silently skipping the member.","triggerScenarios":"Serializing an object graph that contains a struct type with no [DataSerializer]/generated serializer and not in SerializerSelector's known set; a custom type added to a component/asset without running the Stride serializer codegen; a SerializerSelector that excludes the serializer needed for that member type.","commonSituations":"Adding a plain C# struct (e.g. custom vector/ID type) to an EntityComponent without a DataSerializer; forgetting to regenerate the serializer assembly after adding a new serializable type; using a custom SerializerSelector profile that filters out the serializer; referencing a type from an assembly not registered for serialization.","solutions":["Add a [DataSerializer] for the type or make it [DataContract] and regenerate serializers (build with Stride's codegen)","Ensure the assembly containing the type is registered via Serialization.RegisterSerializationAssembly","Check the SerializerSelector/profile actually includes serializers for that type instead of filtering them out","If the type should not be serialized, mark the member [DataMemberIgnore] to exclude it","Register a custom DataSerializer via SerializerSelector registration for third-party types you can't annotate"],"exampleFix":"// before\npublic struct MyId { public int Value; } // no serializer -> ArgumentException\n// after\n[DataContract]\npublic struct MyId { public int Value; }\n// plus regenerate serializer assembly or:\n[DataSerializer(typeof(MyIdSerializer))]","handlingStrategy":"type-guard","validationCode":"// before serializing a struct member, confirm a serializer exists\nvar serializer = context.SerializerSelector.GetSerializer(memberType);\nif (serializer == null) throw new InvalidOperationException($\"No serializer registered for {memberType}\");","typeGuard":"static bool HasSerializer(SerializerSelector selector, Type t) =>\n    selector.GetSerializer(t) is not null;","tryCatchPattern":"try\n{\n    stream.Serialize(ref value);\n}\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"No serializer available\"))\n{\n    logger.Error(ex, \"Add [DataContract]/[DataSerializer] or regenerate serializers for the type in question\");\n    throw;\n}","preventionTips":["Annotate every serialized struct/class with [DataContract] or provide a [DataSerializer]","Rebuild the project after adding serializable types so codegen emits serializers","Keep third-party types out of serialized members, or register custom serializers","Mark non-serialized helpers with [DataMemberIgnore]"],"tags":["serialization","missing-serializer","codegen","stride"],"backgroundTag":"class-not-found","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}