dotnet/orleans · error · NotSupportedException

Specified method is not supported.

Error message

Specified method is not supported.

What it means

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.

Source

Thrown at src/AdoNet/Shared/Storage/OrleansRelationalDownloadStream.cs:95

        public override bool CanRead => _reader != null && (!_reader.IsClosed);

        /// <inheritdoc/>
        public override bool CanSeek => false;

        /// <inheritdoc/>
        public override bool CanTimeout => true;

        /// <inheritdoc/>
        public override bool CanWrite => false;

        /// <inheritdoc/>
        public override long Length => _totalBytes;

        /// <inheritdoc/>
        public override long Position
        {
            get => _position;
            set => throw new NotSupportedException();
        }

        /// <inheritdoc/>
        public override void Flush() => throw new NotSupportedException();

        /// <inheritdoc/>
        public override int Read(byte[] buffer, int offset, int count)
        {
            //This will throw with the same parameter names if the parameters are not valid.
            ValidateReadParameters(buffer, offset, count);

            try
            {
                int length = Math.Min(count, (int)(_totalBytes - _position));
                long bytesRead = 0;
                if (length > 0)
                {
                    bytesRead = _reader.GetBytes(_ordinal, _position, buffer, offset, length);

View on GitHub (pinned to fca799fa70)

Solutions

  1. Do not set Position on this stream; read sequentially from offset 0 forward.
  2. If you need random access, buffer the data first into a MemoryStream and seek that copy.
  3. Check CanSeek (false for this stream) before attempting seek-related operations.

Example fix

// before
stream.Position = 0; // throws NotSupportedException

// after
if (stream.CanSeek) stream.Position = 0;
else { /* buffer into MemoryStream to re-read */ }
Defensive patterns

Strategy: type-guard

Validate before calling

if (!stream.CanSeek) { /* do not set Position; buffer into MemoryStream if random access needed */ }

Type guard

static bool IsSeekable(Stream s) => s.CanSeek;

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13). Data as JSON: /api/errors/b65276273031354c. Report an issue: GitHub.