stride3d/stride · error · InvalidOperationException
The type [ ] cannot be only be used for clone serialization
Error message
The type [{typeof(T).FullName}] cannot be only be used for clone serialization What it means
Internal clone-serialization consistency error in AssetCloner.PreSerialize (deserialization side): the index read from the stream is beyond the count of the invariant-object list gathered during serialization. This clone-serialization helper type can only be used through the cloner, so this indicates mismatched or corrupted clone streams rather than a user-input problem.
Solutions
- Ensure the same cloner configuration produces and consumes the stream
- Avoid reusing/persisting clone streams across versions or configurations
- Report as an engine bug if it reproduces with a self-contained clone operation
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at sources/assets/Stride.Core.Assets/AssetCloner.cs:353 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/344d58d2d3a74f8e.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/AssetCloner.cs:353
{
parentSerializer = serializerSelector.GetSerializer(typeof(T).BaseType!);
}
public override void PreSerialize(ref T obj, ArchiveMode mode, SerializationStream stream)
{
var invariantObjectList = stream.Context.Get(InvariantObjectListProperty)!;
if (mode == ArchiveMode.Serialize)
{
stream.Write(invariantObjectList.Count);
invariantObjectList.Add(obj);
}
else
{
var index = stream.Read<int>();
if (index >= invariantObjectList.Count)
{
throw new InvalidOperationException($"The type [{typeof(T).FullName}] cannot be only be used for clone serialization");
}
if (invariantObjectList[index] is not T invariant)
{
throw new InvalidOperationException($"Unexpected null {typeof(T).FullName} while cloning");
}
// Create a new object to avoid exception in case its identity is important
obj = (T)Activator.CreateInstance(typeof(T), invariant.TypeName, invariant.AssemblyName, invariant.Error, invariant.ParsingEvents)!;
}
}
public override void Serialize(ref T obj, ArchiveMode mode, SerializationStream stream)
{
// Process with parent serializer first
object parentObj = obj;
parentSerializer?.Serialize(ref parentObj, mode, stream);
obj = (T)parentObj;View on GitHub (pinned to 96fad776d2)