stride3d/stride · error · InvalidOperationException

Could not process serialization for member

Error message

Could not process serialization for member {serializableItem.MemberInfo}

What it means

The AssemblyProcessor's serializer dependency collector (CollectSerializerDependencies) throws this when processing a member's serializer raises any exception. It wraps the original exception (inner exception holds the real cause) and names the offending MemberInfo, typically because a serializable member's type has no valid DataSerializer.

Solutions

  1. Read the InnerException for the real cause and fix that underlying serializer issue
  2. Add [DataMemberIgnore] to the offending member if it should not be serialized
  3. Make the member non-public so it is not picked up as serializable
  4. Add [DataContract] (and a DataSerializer if needed) to the member's type
  5. Register a custom DataSerializer for the member's type via [DataSerializer] attribute

Example fix

// before
public class Enemy
{
    public Texture MyTexture { get; set; } // no serializer
}
// after
public class Enemy
{
    [DataMemberIgnore]
    public Texture MyTexture { get; set; }
}
Defensive patterns

Strategy: validation

Validate before calling

// Duplicate guard entry (index repeated in input): audit members before processing
foreach (var member in CollectSerializableMembers(type))
    if (!HasResolvableSerializer(member))
        Console.WriteLine($"[warn] {member} has no serializer; add [DataMemberIgnore] or [DataContract]");

Type guard

static bool HasResolvableSerializer(MemberInfo m) =>
    m.IsDefined(typeof(DataMemberIgnoreAttribute)) || HasSerializer(GetMemberType(m));

Try / catch

try { CollectSerializerDependencies(type); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Could not process serialization for member"))
{
    logger.Error($"{ex.Message} caused by: {ex.InnerException?.Message}");
}

Prevention

When it happens

Trigger: CollectSerializerDependencies hits a member whose resolved type cannot be resolved to a serializer (e.g. a type without [DataContract]/[DataSerializer], an unsupported nested-generic type, or an exception inside the serializer factory); the catch-all wraps it as InvalidOperationException.

Common situations: A user adds a new class to a data contract but forgets [DataContract] or [DataMemberIgnore]; a member references a third-party type the processor cannot serialize; a refactoring introduces a nested type with parent generic parameters.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at sources/core/Stride.Core.AssemblyProcessor/Serializers/CecilSerializerContext.cs:253

            var resolvedType = serializableItem.Type.Resolve();
            var isInterface = resolvedType?.IsInterface == true;

            try
            {
                if (ResolveSerializer(serializableItem.Type, profile: profile) == null)
                {
                    IgnoredMembers.Add(serializableItem.MemberInfo);
                    if (!isInterface)
                    {
                        log.Write(
                            $"Warning: Member {serializableItem.MemberInfo} does not have a valid serializer. Add [DataMemberIgnore], turn the member non-public, or add a [DataContract] to it's type.");
                    }
                }
            }
            catch (Exception e)
            {
                throw new InvalidOperationException($"Could not process serialization for member {serializableItem.MemberInfo}", e);
            }
        }

        // Cache final serializable items (after ignored members have been updated)
        if (descriptor is not null)
            descriptor.SerializableItems = SerializationHelpers.GetSerializableItems(type, true, ignoredMembers: IgnoredMembers).ToArray();
    }

    /// <summary>
    /// Finds the serializer information by inspecting the type's attributes and inheritance chain.
    /// </summary>
    internal SerializableTypeInfo FindSerializerInfo(TypeReference type, bool generic)
    {
        if (type == null || type.FullName == typeof(object).FullName || type.FullName == typeof(ValueType).FullName || type.IsGenericParameter)
            return null;

        var resolvedType = type.Resolve();

View on GitHub (pinned to 96fad776d2)