stride3d/stride · error · InvalidOperationException
The video system has not been added to the services
Error message
The video system has not been added to the services
What it means
VideoInstance's constructor requires a VideoSystem registered in the IServiceRegistry (it derives the graphics device and manages backends). This InvalidOperationException is thrown when services.GetService<VideoSystem>() returns null — the video system service was never added to the service registry.
Solutions
- Register VideoSystem in the service registry before creating VideoInstance (e.g. Services.AddVideoSystem() / new VideoSystem(Services))
- Ensure the same IServiceRegistry instance used by the game is passed to VideoInstance
- For tests/tools, add a VideoSystem (with a GraphicsDevice) to the registry first
Example fix
// before
var videoInstance = new VideoInstance(Services, videoComponent); // throws
// after
if (Services.GetService<VideoSystem>() == null)
Services.AddService(new VideoSystem(Services));
var videoInstance = new VideoInstance(Services, videoComponent); Defensive patterns
Strategy: type-guard
Validate before calling
if (Services.GetService<VideoSystem>() == null)
Services.AddService(new VideoSystem(Services)); Type guard
bool VideoReady(IServiceRegistry s) => s.GetService<VideoSystem>() != null;
Try / catch
try { var vi = new VideoInstance(Services, component); }
catch (InvalidOperationException ex) when (ex.Message.Contains("video system"))
{
Services.AddService(new VideoSystem(Services));
var vi = new VideoInstance(Services, component);
} Prevention
- Register VideoSystem during game/service initialization
- Pass the game's live IServiceRegistry to VideoInstance
- Add an early assertion in startup that VideoSystem resolves
When it happens
Trigger: Constructing a VideoInstance with a service registry that lacks VideoSystem — e.g. forgetting services.AddVideoSystem() during game setup, or creating VideoInstance in a context using a different/partial service registry.
Common situations: Custom SceneSystem/Game setups that skip the default service registration; unit tests constructing VideoInstance with a bare ServiceRegistry; headless tools instantiating video playback.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- Custom strides is not supported with packed PixelFormats
- Media isn't open.
- MicroThread was already started before.
- The folder being deleted is not empty.
- A dependency object must be attached in order to register a…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/093794cacc172f05.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Video/VideoInstance.cs:51
private float volume = 1f;
private float speedFactor = 1f;
private bool mediaInitialized;
private bool isLooping;
private PlayRange loopRange;
private PlayRange playRange;
/// <summary>
/// Initializes a new instance of the <see cref="VideoInstance"/> class.
/// </summary>
public VideoInstance([NotNull] IServiceRegistry services, [NotNull] VideoComponent videoComponent)
: base(services.GetService<IGame>()?.GraphicsDevice)
{
this.services = services ?? throw new ArgumentNullException(nameof(services));
this.videoComponent = videoComponent ?? throw new ArgumentNullException(nameof(videoComponent));
videoSystem = this.services.GetService<VideoSystem>() ?? throw new InvalidOperationException("The video system has not been added to the services");
streamingManager = services.GetService<StreamingManager>();
contentManager = services.GetService<ContentManager>();
currentVideo = videoComponent.Source;
IsLooping = videoComponent.LoopVideo;
}
public static Logger Logger = GlobalLogger.GetLogger(nameof(VideoInstance));
public TimeSpan CurrentTime { get; private set; }
public uint MaxMipMapCount { get; private set; }
/// <summary>The duration of the video.</summary>
public TimeSpan Duration { get; private set; }
/// <summary>The current state of the video.</summary>
public PlayState PlayState { get; private set; } = PlayState.Stopped;View on GitHub (pinned to 96fad776d2)