stride3d/stride · error · InvalidOperationException
Invalid GeometricPrimitive
Error message
Invalid GeometricPrimitive [{0}]. Expecting a non-null Type What it means
ProceduralModelDescriptor.GenerateModel requires its Type property (the IProceduralModel describing the primitive) to be set before generating into the target Model. A null Type throws InvalidOperationException; the descriptor has no primitive to build.
Solutions
- Set descriptor.Type to a PrimitiveProceduralModelBase instance (e.g. new SphereProceduralModel()) before calling GenerateModel
- Fix the asset serialization so Type is saved/loaded (re-save the descriptor asset)
- Guard the call site by checking descriptor.Type != null before invoking GenerateModel
Example fix
// before
var descriptor = new ProceduralModelDescriptor();
descriptor.GenerateModel(services, model); // throws: Type is null
// after
var descriptor = new ProceduralModelDescriptor { Type = new SphereProceduralModel() };
descriptor.GenerateModel(services, model); Defensive patterns
Strategy: validation
Validate before calling
if (descriptor?.Type == null)
throw new InvalidOperationException("ProceduralModelDescriptor.Type must be set before GenerateModel");
descriptor.GenerateModel(services, model); Type guard
static bool IsReady(ProceduralModelDescriptor d) => d?.Type != null;
Try / catch
try { descriptor.GenerateModel(services, model); }
catch (InvalidOperationException ex) when (ex.Message.Contains("non-null Type")) {
descriptor.Type = new CubeProceduralModel(); // sensible default
descriptor.GenerateModel(services, model);
} Prevention
- Always initialize descriptor.Type in object initializers
- Re-save assets after schema changes so Type is serialized
- Unit-test procedural descriptor creation paths for null Type
When it happens
Trigger: Calling GenerateModel on a ProceduralModelDescriptor whose Type was never assigned (e.g. a descriptor created in code without setting Type), or a descriptor whose Type field was reset/deserialized as null.
Common situations: Building procedural models programmatically and forgetting to set descriptor.Type; assets saved by older versions where Type was not serialized; scene/model assets with partially configured primitive descriptors.
Related errors
- Cannot generate more than 65535 indices on feature level HW…
- Invalid GeometricPrimitive
- A texture with size [ ] already exist with the same output…
- Asked for " + i + " but no more than 10 default textures…
- Begin must be called before functionName
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/f473bbb5d5dfd8ee.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Rendering/Rendering/ProceduralModels/ProceduralModelDescriptor.cs:59
[DataMember(10)]
[NotNull]
[Display("Type", Expand = ExpandRule.Always)]
public IProceduralModel Type { get; set; }
public Model GenerateModel(IServiceRegistry services)
{
var model = new Model();
GenerateModel(services, model);
return model;
}
public void GenerateModel(IServiceRegistry services, Model model)
{
if (model == null) throw new ArgumentNullException(nameof(model));
if (Type == null)
{
throw new InvalidOperationException("Invalid GeometricPrimitive [{0}]. Expecting a non-null Type");
}
Type.Generate(services, model);
}
}
}
View on GitHub (pinned to 96fad776d2)