{"record":{"id":"81d735e3efbceae6","repo":"stride3d/stride","slug":"the-type-of-the-retrieved-node-content-does-not-match-the","errorCode":null,"errorMessage":"The type of the retrieved node content does not match the type of this reference","messagePattern":"The type of the retrieved node content does not match the type of this reference","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Quantum/References/ObjectReference.cs","lineNumber":127,"sourceCode":"    {\n        ArgumentNullException.ThrowIfNull(nodeContainer);\n        var targetNode = nodeContainer.GetOrCreateNodeInternal(objectValue);\n        SetTarget(targetNode);\n        return targetNode;\n    }\n\n    /// <summary>\n    /// Set the <see cref=\"TargetNode\"/> and <see cref=\"TargetGuid\"/> of the targeted object by retrieving it from or creating it to the given <see cref=\"NodeContainer\"/>.\n    /// </summary>\n    /// <param name=\"targetNode\">The <see cref=\"NodeContainer\"/> used to retrieve or create the target node.</param>\n    internal IObjectNode? SetTarget(IObjectNode? targetNode)\n    {\n        if (targetNode != null)\n        {\n            var targetValue = targetNode.Retrieve();\n\n            if (targetValue != null && !type.IsInstanceOfType(targetValue))\n                throw new InvalidOperationException(\"The type of the retrieved node content does not match the type of this reference\");\n\n            TargetNode = targetNode;\n            TargetGuid = targetNode.Guid;\n        }\n        else\n        {\n            TargetNode = null;\n            TargetGuid = Guid.Empty;\n        }\n\n        return targetNode;\n    }\n}\n","sourceCodeStart":109,"sourceCodeEnd":141,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Quantum/References/ObjectReference.cs#L109-L141","documentation":"Thrown by ObjectReference.SetTarget when the content retrieved from the target node does not match this reference's declared type. After resolving or creating the target IObjectNode in the NodeContainer, the reference validates that the node's content is actually of its type; a mismatch means the reference pointed at a node holding a different kind of object, which would make later TargetNode.Retrieve accesses type-unsafe, so an InvalidOperationException is thrown.","triggerScenarios":"Thrown at sources/presentation/Stride.Core.Quantum/References/ObjectReference.cs:127 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the object registered in the NodeContainer under that identity is actually of the reference's type; recreate the ObjectReference with the correct type if the model changed.","Verify that the objectValue used with GetOrCreateNodeInternal is the same instance/version the reference was created for — stale or replaced objects produce mismatched node content.","Before binding, compare the retrieved node's content type with the reference's type and re-create the reference rather than forcing SetTarget."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}