{"record":{"id":"e766ec724e9874e5","repo":"dotnet/wpf","slug":"sr-seeknotsupported","errorCode":null,"errorMessage":"SR.SeekNotSupported","messagePattern":"SR\\.SeekNotSupported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CFStream.cs","lineNumber":146,"sourceCode":"    public override void Flush()\n    {\n        CheckDisposedStatus();\n        _safeIStream.Commit(0);\n    }\n\n    /// <summary>\n    /// See .NET Framework SDK under System.IO.Stream\n    /// </summary>\n    /// <param name=\"offset\">Offset byte count</param>\n    /// <param name=\"origin\">Offset origin</param>\n    /// <returns></returns>\n    public override long Seek( long offset, SeekOrigin origin )\n    {\n        CheckDisposedStatus();\n\n        if (!CanSeek)\n        {\n            throw new NotSupportedException(SR.SeekNotSupported);\n        }\n        \n        // \n        long seekPos = 0;\n        int translatedSeekOrigin = 0;\n\n        switch(origin)\n        {\n            case SeekOrigin.Begin:\n                translatedSeekOrigin = SafeNativeCompoundFileConstants.STREAM_SEEK_SET;\n                if( 0 > offset )\n                {\n                    throw new ArgumentOutOfRangeException(nameof(offset),\n                        SR.SeekNegative);\n                }\n                break;\n            case SeekOrigin.Current:\n                translatedSeekOrigin = SafeNativeCompoundFileConstants.STREAM_SEEK_CUR;","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CFStream.cs#L128-L164","documentation":"CFStream.Seek throws NotSupportedException with SR.SeekNotSupported when CanSeek is false, i.e. the underlying compound-file stream cannot be seeked in its current state (e.g. write/append-only). Any explicit Seek call is rejected before contacting IStream.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/WindowsBase/MS/Internal/IO/Packaging/CompoundFile/CFStream.cs:146 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check CanSeek before calling Seek on the CFStream","Do not attempt seek operations on a stream opened over an IStream without seek capability","Buffer or copy the content into a seekable MemoryStream if seeking is required"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}