abpframework/abp · error · NotSupportedException
Specified method is not supported.
Error message
Specified method is not supported.
What it means
LeaveOpenStreamWrapper.SetLength and Write throw a bare NotSupportedException (whose default .NET message is 'Specified method is not supported.'). The wrapper is intentionally read-only (CanWrite is hardcoded false) because it exists solely to feed bytes to the AWS SDK upload without surrendering ownership of the underlying stream. Any attempt to mutate length or write through it is rejected.
Source
Thrown at framework/src/Volo.Abp.BlobStoring.Aws/Volo/Abp/BlobStoring/Aws/LeaveOpenStreamWrapper.cs:86
return _inner.ReadAsync(buffer, offset, count, cancellationToken);
#else
// The SDK reads over this (old) overload; dispatch it over the modern one,
// so a source that only implements ReadAsync(Memory<byte>) keeps working
return _inner.ReadAsync(buffer.AsMemory(offset, count), cancellationToken).AsTask();
#endif
}
#if !NETSTANDARD2_0
public override int Read(Span<byte> buffer) => _inner.Read(buffer);
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
{
return _inner.ReadAsync(buffer, cancellationToken);
}
#endif
public override long Seek(long offset, SeekOrigin origin) => _inner.Seek(offset, origin);
public override void SetLength(long value) => throw new NotSupportedException();
public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException();
// Disposing the wrapper must not dispose the wrapped stream
}
View on GitHub (pinned to 7ed43b1931)
Solutions
- Do not write to or set length on the wrapper; it is an upload-only forwarder.
- If you need a readable+writable stream, use a MemoryStream instead of the wrapper.
- Keep the LeaveOpenStreamWrapper internal to the AWS provider path and never expose it to callers.
Example fix
// before (incorrect) wrapper.Write(buffer, 0, buffer.Length); // after using var memStream = new MemoryStream(); memStream.Write(buffer, 0, buffer.Length); memStream.Position = 0; await container.SaveAsync(name, memStream);
Defensive patterns
Strategy: validation
Validate before calling
// Never call Write/SetLength on LeaveOpenStreamWrapper. If you need a writable stream: var writable = new MemoryStream(); writable.Write(buffer, 0, buffer.Length); writable.Position = 0; await container.SaveAsync(name, writable);
Type guard
if (!stream.CanWrite) throw new InvalidOperationException("Stream is not writable; cannot Write/SetLength."); Try / catch
try { wrapper.Write(buffer, 0, buffer.Length); }
catch (NotSupportedException) { /* do not write to the read-only wrapper */ } Prevention
- Treat LeaveOpenStreamWrapper as read-only upload forwarder.
- Do not expose internal provider wrappers to application code.
- Use MemoryStream when a writable buffer is required.
When it happens
Trigger: Calling SetLength or Write (or WriteAsync via the base) on a LeaveOpenStreamWrapper instance. This happens when code mistakenly treats the wrapper as a writable stream, or when a stream-copy helper tries to write into it.
Common situations: Custom code that wraps the AWS provider and attempts to write back into the upload stream, misuse of the internal wrapper, or a generic stream-processing utility that writes to whatever Stream it receives.
Related errors
- The length of the stream is not available!
- The position of the stream is not available!
- Saving BLOB '{args.BlobName}' does already exists in the con
- Saving BLOB '{args.BlobName}' does already exists in the con
- Either Region or ServiceURL must be configured on AwsBlobPro
AI-assisted analysis of abpframework/abp@7ed43b1931 (2026-08-13).
Data as JSON: /api/errors/575ad24daaccaadd.
Report an issue: GitHub.