{"record":{"id":"093794cacc172f05","repo":"stride3d/stride","slug":"the-video-system-has-not-been-added-to-the-services","errorCode":null,"errorMessage":"The video system has not been added to the services","messagePattern":"The video system has not been added to the services","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Video/VideoInstance.cs","lineNumber":51,"sourceCode":"        private float volume = 1f;\n        private float speedFactor = 1f;\n\n        private bool mediaInitialized;\n\n        private bool isLooping;\n        private PlayRange loopRange;\n        private PlayRange playRange;\n\n        /// <summary>\n        /// Initializes a new instance of the <see cref=\"VideoInstance\"/> class.\n        /// </summary>\n        public VideoInstance([NotNull] IServiceRegistry services, [NotNull] VideoComponent videoComponent)\n            : base(services.GetService<IGame>()?.GraphicsDevice)\n        {\n            this.services = services ?? throw new ArgumentNullException(nameof(services));\n            this.videoComponent = videoComponent ?? throw new ArgumentNullException(nameof(videoComponent));\n\n            videoSystem = this.services.GetService<VideoSystem>() ?? throw new InvalidOperationException(\"The video system has not been added to the services\");\n            streamingManager = services.GetService<StreamingManager>();\n            contentManager = services.GetService<ContentManager>();\n\n            currentVideo = videoComponent.Source;\n            IsLooping = videoComponent.LoopVideo;\n        }\n\n        public static Logger Logger = GlobalLogger.GetLogger(nameof(VideoInstance));\n\n        public TimeSpan CurrentTime { get; private set; }\n\n        public uint MaxMipMapCount { get; private set; }\n\n        /// <summary>The duration of the video.</summary>\n        public TimeSpan Duration { get; private set; }\n\n        /// <summary>The current state of the video.</summary>\n        public PlayState PlayState { get; private set; } = PlayState.Stopped;","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Video/VideoInstance.cs#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"Custom SceneSystem/Game setups that skip the default service registration; unit tests constructing VideoInstance with a bare ServiceRegistry; headless tools instantiating video playback.","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"],"exampleFix":"// before\nvar videoInstance = new VideoInstance(Services, videoComponent); // throws\n// after\nif (Services.GetService<VideoSystem>() == null)\n    Services.AddService(new VideoSystem(Services));\nvar videoInstance = new VideoInstance(Services, videoComponent);","handlingStrategy":"type-guard","validationCode":"if (Services.GetService<VideoSystem>() == null)\n    Services.AddService(new VideoSystem(Services));","typeGuard":"bool VideoReady(IServiceRegistry s) => s.GetService<VideoSystem>() != null;","tryCatchPattern":"try { var vi = new VideoInstance(Services, component); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"video system\"))\n{\n    Services.AddService(new VideoSystem(Services));\n    var vi = new VideoInstance(Services, component);\n}","preventionTips":["Register VideoSystem during game/service initialization","Pass the game's live IServiceRegistry to VideoInstance","Add an early assertion in startup that VideoSystem resolves"],"tags":["service-registration","invalid-operation","video","stride"],"backgroundTag":"missing-dependency","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}