stride3d/stride · error · InvalidOperationException

Unable to retrieve the value of this member path on this…

Error message

Unable to retrieve the value of this member path on this root object.

What it means

GetValue() is the throwing wrapper around TryGetValue(): when the path cannot be resolved against the given root object (a segment doesn't match, an intermediate object is null, or the path is empty), TryGetValue returns false and GetValue throws InvalidOperationException. It signals that this MemberPath does not fit this root object.

Solutions

  1. Use TryGetValue(root, out var value) and handle the false case instead of catching the exception.
  2. Verify the path was built from the same (or structurally identical) type as the root object.
  3. Ensure every intermediate object along the path is non-null (call CreateIntermediateObjects or initialize them) and indices/keys exist.
  4. Rebuild the MemberPath against the current type if the schema changed.

Example fix

// before
var value = path.GetValue(root);
// after
if (path.TryGetValue(root, out var value))
{
    // use value
}
else
{
    // path does not resolve on this root
}
Defensive patterns

Strategy: try-catch

Validate before calling

bool resolvable = path.TryGetValue(root, out _);

Try / catch

try { var v = path.GetValue(root); }
catch (InvalidOperationException ex) when (ex.Message.Contains("Unable to retrieve the value")) { /* fall back to TryGetValue handling */ }

Prevention

When it happens

Trigger: Calling path.GetValue(root) where root lacks a member named in the path, an intermediate value along the path is null, an index is out of range, or the path instance was never populated.

Common situations: Applying a MemberPath recorded from one object graph to a different/incompatible root; schema or version drift renaming properties so the stored path no longer resolves; null navigation chains in the target object.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/5eb2ad3026f4b55b. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Reflection/MemberPath.cs:343

    public object? GetIndex()
    {
        return items.LastOrDefault()?.GetIndex();
    }

    /// <summary>
    /// Gets the type descriptor of the member or collection represented by this path, or <c>null</c> is this instance is an empty path.
    /// </summary>
    /// <returns>The type descriptor of the member or collection represented by this path, or <c>null</c> is this instance is an empty path.</returns>
    public ITypeDescriptor? GetTypeDescriptor()
    {
        return items.LastOrDefault()?.TypeDescriptor;
    }

    public object? GetValue(object rootObject)
    {
        if (!TryGetValue(rootObject, out var result))
            throw new InvalidOperationException("Unable to retrieve the value of this member path on this root object.");
        return result;
    }

    /// <summary>
    /// Gets the value from the specified root object following this instance path.
    /// </summary>
    /// <param name="rootObject">The root object.</param>
    /// <param name="value">The returned value.</param>
    /// <returns><c>true</c> if evaluation of the path succeeded and the value is valid, <c>false</c> otherwise.</returns>
    /// <exception cref="ArgumentNullException">rootObject</exception>
    public bool TryGetValue(object rootObject, out object? value)
    {
        ArgumentNullException.ThrowIfNull(rootObject);
        value = null;
        try
        {
            object nextObject = rootObject;
            for (int i = 0; i < items.Count; i++)

View on GitHub (pinned to 96fad776d2)