{"record":{"id":"b963faa069df5cf2","repo":"stride3d/stride","slug":"can-to-detach-camera-camera-entity-name-from-the-graphics","errorCode":null,"errorMessage":"Can'to detach camera [{camera.Entity.Name}] from the graphics compositor. Another camera, {slot.Camera.Entity.Name}, is attached to this slot.","messagePattern":"Can'to detach camera \\[(.+?)\\] from the graphics compositor\\. Another camera, (.+?), is attached to this slot\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/Processors/CameraProcessor.cs","lineNumber":160,"sourceCode":"                    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        {\n            for (var i = 0; i < graphicsCompositor.Cameras.Count; ++i)\n            {\n                var slot = graphicsCompositor.Cameras[i];\n                if (slot.Camera == camera)\n                {\n                    slot.Camera = null;\n                }\n            }","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/Processors/CameraProcessor.cs#L142-L178","documentation":"DetachCameraFromSlot throws InvalidOperationException when the compositor slot matching the camera's slot id is occupied by a different camera, so the requested camera cannot be the one detached from that slot.","triggerScenarios":"The camera's Slot.Id equals an occupied slot, but slot.Camera points to another camera component — e.g. after swapping Slot.Id values between two cameras, or attaching camera B to a slot then trying to detach camera A whose slot id matches.","commonSituations":"Swapping or reusing camera slot IDs at runtime; copying slot settings between camera components; a new camera attached to the slot after the old one's attachment bookkeeping was lost.","solutions":["Ensure the Slot.Id being detached still points at the slot this camera actually occupies","Detach before changing a camera's Slot.Id","Reset camera.Slot.AttachedCompositor = null when it is known to be stale, then attach cleanly","Keep one camera per slot and avoid mutating Slot.Id on attached cameras"],"exampleFix":"// before\ncamera.Slot.Id = otherId; // slot bookkeeping now inconsistent\nDetach(camera);\n// after\nDetach(camera);           // detach first\ncamera.Slot.Id = otherId;","handlingStrategy":"validation","validationCode":"var slot = camera.Slot.AttachedCompositor?.Cameras.FirstOrDefault(s => s.Id == camera.Slot.Id);\nif (slot == null || slot.Camera != camera) return; // wrong camera in slot","typeGuard":null,"tryCatchPattern":"try { DetachCameraFromSlot(camera); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"Another camera\")) { /* re-sync slot bookkeeping */ }","preventionTips":["Detach a camera before changing its Slot.Id","Never swap Slot.Id values between attached cameras","Keep one camera per slot and one slot per attached camera","Reset stale AttachedCompositor references before re-attaching"],"tags":["graphics","camera","slot-conflict"],"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"}