stride3d/stride · error · InvalidOperationException
Could not find a valid content serializer for
Error message
Could not find a valid content serializer for {typeof(T)} when loading {contentReference.Location} What it means
ReferenceSerializer<T>.Serialize resolves a content serializer for T when serializing a content reference. If neither the cached serializer nor the one derived from the stored chunk header type can be resolved, the library cannot construct or serialize the referenced content and throws.
Solutions
- Ensure the assembly containing the referenced content type is loaded (AssemblyRegistry) before deserialization
- Register a serializer for the concrete content type of the asset
- Rebuild/re-save the asset so its chunk header matches a currently registered type
- Verify the contentReference.Location points to the intended asset of a serializable type
Example fix
// before
// plugin assembly with MyAssetType never loaded
var asset = contentManager.Load<MyAssetType>("my-asset"); // throws
// after
AssemblyRegistry.Register(typeof(MyAssetType).Assembly);
var asset = contentManager.Load<MyAssetType>("my-asset"); Defensive patterns
Strategy: try-catch
Validate before calling
if (AssemblyRegistry.GetType(chunkType) == null)
throw new InvalidOperationException("Assembly for asset type not loaded"); Try / catch
try { var asset = contentManager.Load<T>(location); }
catch (InvalidOperationException ex) when (ex.Message.Contains("valid content serializer")) { // ensure assembly/serializer registered
} Prevention
- Keep plugin/content assemblies referenced by the app
- Re-save assets after type renames or assembly moves
- Register content serializers at startup before loading assets
When it happens
Trigger: Serializing/deserializing a content reference whose Location points to content of a type with no registered serializer, or whose chunk header type fails AssemblyRegistry.GetType resolution (assembly not loaded or removed).
Common situations: Loading assets built with types from an assembly no longer referenced; a plugin/asset type removed in a version upgrade; corrupt or hand-edited asset files with unknown chunk types.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Unable to find a serializer for
- Unable to find a serializer for
- Could not find serializer for generic dependent type
- Can't find serializer for type
- SetAssetObject has already been called with a different…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/eb563365dcec02a0.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ReferenceSerializer.cs:61
// Check if already deserialized
var assetReference = contentSerializerContext.ContentManager.FindDeserializedObject(contentReference.Location, typeof(T));
if (assetReference != null)
{
obj = (T)assetReference.Object;
if (obj != null)
contentReference.Value = obj;
}
}
if (obj == null && contentSerializerContext.LoadContentReferences)
{
var contentSerializer = cachedContentSerializer ??= contentSerializerContext.ContentManager.Serializer.GetSerializer(null, typeof(T));
if (contentSerializer == null)
{
// Need to read chunk header to know actual type (note that we can't cache it in cachedContentSerializer as it depends on content)
var chunkHeader = contentSerializerContext.ContentManager.ReadChunkHeader(contentReference.Location);
if (chunkHeader == null || (contentSerializer = contentSerializerContext.ContentManager.Serializer.GetSerializer(AssemblyRegistry.GetType(chunkHeader.Type), typeof(T))) == null)
throw new InvalidOperationException($"Could not find a valid content serializer for {typeof(T)} when loading {contentReference.Location}");
}
// First time, let's create it
if (contentSerializerContext.ContentManager.Exists(contentReference.Location))
{
obj = (T)contentSerializer.Construct(contentSerializerContext);
contentSerializerContext.ContentManager.RegisterDeserializedObject(contentReference.Location, obj);
contentReference.Value = obj;
}
}
}
}
else if (referenceSerialization == ContentSerializerContext.AttachedReferenceSerialization.AsNull)
{
if (mode == ArchiveMode.Deserialize)
{
obj = default;
}View on GitHub (pinned to 96fad776d2)