stride3d/stride · error · InvalidOperationException

Content serializer for

Error message

Content serializer for {obj.GetType()} could not be found.

What it means

Serializer resolution failure in ContentManager.SerializeObject: no content serializer could be found for the concrete type of the object being saved, so the object graph cannot be written. Typically the type lives in an assembly not registered with the serialization system or has no DataContract/serializer support.

Solutions

  1. Ensure the object's assembly is registered (AssemblyRegistry) so its serializers are discovered
  2. Mark the type as serializable (DataContract) or provide a matching DataSerializer
  3. If serializing by storage type, pass a storageType that has a registered serializer
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ContentManager.cs:566 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/46346dd96fa2dc73. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ContentManager.cs:566

            var serializeOperation = serializeOperations.Dequeue();
            SerializeObject(serializeOperations, serializeOperation.Url, serializeOperation.Object, serializeOperation.PublicReference, serializeOperation.StorageType);
        }
    }

    private void SerializeObject(Queue<SerializeOperation> serializeOperations, string url, object obj, bool publicReference, Type storageType = null)
    {
        // Don't create context in case we don't want to serialize referenced objects
        //if (!SerializeReferencedObjects && obj != RootObject)
        //    return null;

        // Already saved?
        // TODO: Ref counting? Should we change it on save? Probably depends if we cache or not.
        if (LoadedAssetReferences.ContainsKey(obj))
            return;

        var serializer = Serializer.GetSerializer(storageType, obj.GetType());
        if (serializer == null)
            throw new InvalidOperationException($"Content serializer for {obj.GetType()} could not be found.");

        var contentSerializerContext = new ContentSerializerContext(url, ArchiveMode.Serialize, this);

        using (var stream = FileProvider.OpenStream(url, VirtualFileMode.Create, VirtualFileAccess.Write))
        {
            var streamWriter = new BinarySerializationWriter(stream);
            PrepareSerializerContext(contentSerializerContext, streamWriter.Context);

            ChunkHeader? header = null;

            // Allocate space in the stream, and also include header version in the hash computation, which is better
            // If serialization type is null, it means there should be no header.
            var serializationType = serializer.SerializationType;
            if (serializationType != null)
            {
                header = new ChunkHeader { Type = serializer.SerializationType.AssemblyQualifiedName };
                header.Write(streamWriter);
                header.OffsetToObject = (int)streamWriter.UnderlyingStream.Position;

View on GitHub (pinned to 96fad776d2)