{"record":{"id":"b65276273031354c","repo":"dotnet/orleans","slug":"specified-method-is-not-supported","errorCode":null,"errorMessage":"Specified method is not supported.","messagePattern":"Specified method is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/AdoNet/Shared/Storage/OrleansRelationalDownloadStream.cs","lineNumber":95,"sourceCode":"        public override bool CanRead => _reader != null && (!_reader.IsClosed);\n\n        /// <inheritdoc/>\n        public override bool CanSeek => false;\n\n        /// <inheritdoc/>\n        public override bool CanTimeout => true;\n\n        /// <inheritdoc/>\n        public override bool CanWrite => false;\n\n        /// <inheritdoc/>\n        public override long Length => _totalBytes;\n\n        /// <inheritdoc/>\n        public override long Position\n        {\n            get => _position;\n            set => throw new NotSupportedException();\n        }\n\n        /// <inheritdoc/>\n        public override void Flush() => throw new NotSupportedException();\n\n        /// <inheritdoc/>\n        public override int Read(byte[] buffer, int offset, int count)\n        {\n            //This will throw with the same parameter names if the parameters are not valid.\n            ValidateReadParameters(buffer, offset, count);\n\n            try\n            {\n                int length = Math.Min(count, (int)(_totalBytes - _position));\n                long bytesRead = 0;\n                if (length > 0)\n                {\n                    bytesRead = _reader.GetBytes(_ordinal, _position, buffer, offset, length);","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/AdoNet/Shared/Storage/OrleansRelationalDownloadStream.cs#L77-L113","documentation":"Thrown by the OrleansRelationalDownloadStream.Position setter with the default NotSupportedException message 'Specified method is not supported.' This stream is a forward-only, non-seekable read-only wrapper around a DbDataReader column; it deliberately disallows seeking, so assigning Position is unsupported.","triggerScenarios":"Calling stream.Position = someValue on an OrleansRelationalDownloadStream instance (the stream returned when reading a BLOB column from a relational provider that lacks native GetStream). Also triggered by any framework code that attempts to seek by setting Position.","commonSituations":"Code that treats any Stream as seekable (e.g. serialization helpers, compression, or copying logic that resets Position); attempting to rewind a download stream for a second read; interoperating with a library that sets Position before reading.","solutions":["Do not set Position on this stream; read sequentially from offset 0 forward.","If you need random access, buffer the data first into a MemoryStream and seek that copy.","Check CanSeek (false for this stream) before attempting seek-related operations."],"exampleFix":"// before\nstream.Position = 0; // throws NotSupportedException\n\n// after\nif (stream.CanSeek) stream.Position = 0;\nelse { /* buffer into MemoryStream to re-read */ }","handlingStrategy":"type-guard","validationCode":"if (!stream.CanSeek) { /* do not set Position; buffer into MemoryStream if random access needed */ }","typeGuard":"static bool IsSeekable(Stream s) => s.CanSeek;","tryCatchPattern":null,"preventionTips":["Always check CanSeek before setting Position or calling Seek.","Buffer forward-only streams into a MemoryStream when random access is required.","Avoid generic stream helpers that assume seekability."],"tags":["adonet","stream","not-supported","blob","database","orleans"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}