{"record":{"id":"7a18a7f584e78c88","repo":"stride3d/stride","slug":"failed-to-find-mesh-buffers-while-attempting-to","errorCode":null,"errorMessage":"Failed to find mesh buffers while attempting to FetchBufferContentOrThrow. Make sure that the mesh is either an asset on disk, or has its buffer data attached to the buffer through 'AttachedReference'\n","messagePattern":"Failed to find mesh buffers while attempting to FetchBufferContentOrThrow\\. Make sure that the mesh is either an asset on disk, or has its buffer data attached to the buffer through 'AttachedReference'\n","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/MeshExtension.cs","lineNumber":83,"sourceCode":"                return true;\n            }\n\n            // Compute next offset (if automatic)\n            offset += elementSize;\n        }\n\n        result = default;\n        return false;\n    }\n\n    /// <inheritdoc cref=\"TryFetchBufferContent\"/>\n    /// <remarks> Same as <see cref=\"TryFetchBufferContent\"/> but throws on failure </remarks>\n    internal static byte[] FetchBufferContentOrThrow(Buffer buffer, IServiceRegistry services)\n    {\n        var data = TryFetchBufferContent(buffer, services);\n        if (data is null || data.Length == 0)\n        {\n            throw new InvalidOperationException(\n                $\"Failed to find mesh buffers while attempting to {nameof(FetchBufferContentOrThrow)}. \" +\n                $\"Make sure that the mesh is either an asset on disk, or has its buffer data attached to the buffer through '{nameof(AttachedReference)}'\\n\");\n        }\n\n        return data;\n    }\n\n    /// <summary> Get buffer content from GPU, shared memory or disk </summary>\n    internal static byte[]? TryFetchBufferContent(Buffer buffer, IServiceRegistry services)\n    {\n        var bufRef = AttachedReferenceManager.GetAttachedReference(buffer);\n        if (bufRef?.Data != null && ((BufferData)bufRef.Data).Content is { } output)\n            return output;\n\n        // Try to load it from disk, a file provider is required, editor does not provide one\n        if (bufRef?.Url != null && services.GetService<IDatabaseFileProviderService>() is {} provider && provider.FileProvider is not null)\n        {\n            // We have to create a new one without providing services to ensure that it dumps the graphics buffer data to the attached reference below","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/MeshExtension.cs#L65-L101","documentation":"FetchBufferContentOrThrow fetches the raw byte content of a mesh Buffer from its asset on disk or from data attached via AttachedReference. If TryFetchBufferContent returns null or empty, the buffer has no resolvable backing data, and this InvalidOperationException is thrown with guidance to attach data or keep the asset available.","triggerScenarios":"Calling MeshExtension.FetchBufferContentOrThrow on a buffer whose AttachedReference.Content is null/empty AND whose source asset (via AttachedReference Url/Id) cannot be found on disk or is not a supported mesh asset.","commonSituations":"Runtime-created buffers with no AttachedReference data (e.g. dynamic/gpu-written buffers); mesh assets deleted, moved, or not packaged with the build; running in an environment without the asset database (IServiceRegistry lacking asset services); reading geometry from a mesh that was never persisted.","solutions":["Ensure the mesh is a serialized asset present at its AttachedReference Url, or manually set buffer.AttachedReference.Content with the raw index/vertex data.","Include the mesh asset files in the build output/package.","Call TryFetchBufferContent first if you want to handle missing data gracefully instead of throwing.","Verify the IServiceRegistry passed in has the asset/ContentManager services registered."],"exampleFix":"// before\nvar data = MeshExtension.FetchBufferContentOrThrow(runtimeOnlyBuffer, services); // throws\n// after\nvar data = runtimeOnlyBuffer.AttachedReference?.Content ??\n           MeshExtension.FetchBufferContentOrThrow(runtimeOnlyBuffer, services);","handlingStrategy":"try-catch","validationCode":"var attached = buffer.AttachedReference;\nbool hasData = (attached?.Content is { Length: > 0 }) ||\n               (attached?.Url != null && services.SafeGetAsset(attached.Url) != null);","typeGuard":"bool HasFetchableContent(Buffer b) => b.AttachedReference?.Content is { Length: > 0 } || b.AttachedReference?.Url is not null;","tryCatchPattern":"try { data = MeshExtension.FetchBufferContentOrThrow(buffer, services); }\ncatch (InvalidOperationException ex)\n{ log.Error(\"mesh buffer data unavailable: ensure asset packaged or AttachedReference.Content set\", ex); }","preventionTips":["Package mesh assets with the build","Set AttachedReference.Content for runtime-generated buffers you need to read","Prefer TryFetchBufferContent when absence is expected"],"tags":["csharp","graphics","assets"],"backgroundTag":"resource-not-found","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"}