{"record":{"id":"13c3015538b05f04","repo":"stride3d/stride","slug":"the-camera-camera-entity-name-isn-t-attached","errorCode":null,"errorMessage":"The camera [{camera.Entity.Name}] isn't attached","messagePattern":"The camera \\[(.+?)\\] isn't attached","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/Processors/CameraProcessor.cs","lineNumber":152,"sourceCode":"            for (var i = 0; i < graphicsCompositor.Cameras.Count; ++i)\n            {\n                var slot = graphicsCompositor.Cameras[i];\n                if (slot.Id == camera.Slot.Id)\n                {\n                    if (slot.Camera != null)\n                        throw new InvalidOperationException($\"Unable to attach camera [{camera.Entity.Name}] to the graphics compositor. Another camera, [{slot.Camera.Entity.Name}], is enabled and already attached to this slot.\");\n\n                    slot.Camera = camera;\n                    camera.Slot.AttachedCompositor = graphicsCompositor;\n                    break;\n                }\n            }\n        }\n\n        private static void DetachCameraFromSlot(CameraComponent camera)\n        {\n            if (camera.Slot.AttachedCompositor == null)\n                throw new InvalidOperationException($\"The camera [{camera.Entity.Name}] isn't attached\");\n\n            for (var i = 0; i < camera.Slot.AttachedCompositor.Cameras.Count; ++i)\n            {\n                var slot = camera.Slot.AttachedCompositor.Cameras[i];\n                if (slot.Id == camera.Slot.Id)\n                {\n                    if (slot.Camera != camera)\n                        throw new InvalidOperationException($\"Can'to detach camera [{camera.Entity.Name}] from the graphics compositor. Another camera, {slot.Camera.Entity.Name}, is attached to this slot.\");\n\n                    slot.Camera = null;\n                    break;\n                }\n            }\n            camera.Slot.AttachedCompositor = null;\n        }\n\n        private static void DetachCameraFromAllSlots(CameraComponent camera, GraphicsCompositor graphicsCompositor)\n        {","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/Processors/CameraProcessor.cs#L134-L170","documentation":"DetachCameraFromSlot throws InvalidOperationException when the given CameraComponent's Slot has no AttachedCompositor, meaning the camera is not currently attached anywhere and thus cannot be detached.","triggerScenarios":"Calling detach logic (via the Draw pass or OnEntityComponentRemoved) on a camera whose Slot.AttachedCompositor is null: it was never attached, was already detached, or its Slot was changed while attached.","commonSituations":"Removing a camera entity from a scene that was never attached; double-detach; reassigning camera.Slot (nulls/replaces attachment state) then removing the entity; disabling cameras and assuming detach is always safe.","solutions":["Check camera.Slot?.AttachedCompositor != null before detaching","Ensure the detach path is idempotent: skip instead of throwing when not attached","Don't change camera.Slot while it is attached; detach first, then reassign","If removing an entity, verify the camera went through the attach path in this processor"],"exampleFix":"// before\ncameraProcessor.DetachCameraFromSlot(camera);\n// after\nif (camera.Slot.AttachedCompositor != null)\n    cameraProcessor.DetachCameraFromSlot(camera);","handlingStrategy":"type-guard","validationCode":"if (camera.Slot?.AttachedCompositor == null) return; // nothing to detach","typeGuard":"bool CanDetach(CameraComponent c) => c?.Slot?.AttachedCompositor != null;","tryCatchPattern":"try { DetachCameraFromSlot(camera); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"isn't attached\")) { /* already detached; ignore */ }","preventionTips":["Make detach paths idempotent (check before detaching)","Don't change camera.Slot while attached; detach first","Track attachment state in your own code to avoid double-detach","Only remove camera entities that went through attach"],"tags":["graphics","camera","stride"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}