jstedfast/MailKit · error · NotSupportedException
The stream does not support seeking.
Error message
The stream does not support seeking.
What it means
ProgressStream.Seek is deliberately not implemented: the wrapper exists to report read progress on forward-only streams (e.g. network/HTTP streams), which cannot reposition. It throws NotSupportedException with the message "The stream does not support seeking." whenever Seek is called.
Solutions
- Avoid seeking; read the stream sequentially from start to end
- If random access is needed, buffer the source into a MemoryStream first and wrap that in ProgressStream
- Check CanSeek before calling Seek and use an alternative code path
Example fix
// before
progressStream.Seek(0, SeekOrigin.Begin);
// after
if (progressStream.CanSeek)
progressStream.Seek(0, SeekOrigin.Begin);
else {
using var buffered = new MemoryStream();
progressStream.CopyTo(buffered);
buffered.Seek(0, SeekOrigin.Begin);
} Defensive patterns
Strategy: type-guard
Type guard
bool CanSeekSafely(Stream s) => s.CanSeek; // check before calling Seek/Position
Try / catch
try { stream.Seek(0, SeekOrigin.Begin); }
catch (NotSupportedException) { /* non-seekable: buffer or re-open instead */ } Prevention
- Check Stream.CanSeek before any Seek or Position assignment
- Copy to MemoryStream when random access is required
- Treat network-backed streams as forward-only
When it happens
Trigger: Calling stream.Seek(...) or stream.Position = ... on a ProgressStream; setting Stream.Position (which internally calls Seek); code paths like TestSeek or reading Position that require seekability.
Common situations: Passing a ProgressStream to APIs that assume a seekable Stream (media players, ZipArchive with default mode, serializers that rewind); copying code that worked with FileStream/ MemoryStream to a network-backed stream.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- NotSupportedException
- null
- The stream does not support resizing.
- The folder does not support partial searches.
- The folder does not support partial sorts.
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/6b8a641c1280284d.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/ProgressStream.cs:159
public override void Write (byte[] buffer, int offset, int count)
{
Source.Write (buffer, offset, count);
if (count > 0)
Update (count);
}
public override async Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken)
{
await Source.WriteAsync (buffer, offset, count, cancellationToken).ConfigureAwait (false);
if (count > 0)
Update (count);
}
public override long Seek (long offset, SeekOrigin origin)
{
throw new NotSupportedException ("The stream does not support seeking.");
}
public void Flush (CancellationToken cancellationToken)
{
if (cancellable != null)
cancellable.Flush (cancellationToken);
else
Source.Flush ();
}
public override void Flush ()
{
Source.Flush ();
}
public override Task FlushAsync (CancellationToken cancellationToken)
{
return Source.FlushAsync (cancellationToken);View on GitHub (pinned to 9d3859a785)