{"record":{"id":"d58dff7b87507c5c","repo":"dotnet/wpf","slug":"0x80041705-d58dff","errorCode":"0x80041705","errorMessage":"GetText operation is not supported on current chunk.","messagePattern":"GetText operation is not supported on current chunk\\.","errorType":"error_code","errorClass":"COMException","httpStatus":null,"severity":"warning","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/PackageFilter.cs","lineNumber":226,"sourceCode":"                    //\n                    // No more filters. Filtering completed.\n                    // Throw FILTER_E_END_OF_CHUNKS exception.\n                    //\n\n                    throw new COMException(SR.FilterEndOfChunks,\n                        (int)FilterErrorCode.FILTER_E_END_OF_CHUNKS);\n                }\n            } \n        }\n\n        /// <summary>\n        /// Gets text content corresponding to current chunk.\n        /// </summary>\n        public void GetText(ref uint bufferCharacterCount, IntPtr pBuffer)\n        {\n            if (_progress != Progress.FilteringContent)\n            {\n                throw new COMException(SR.FilterGetTextNotSupported, \n                    (int)FilterErrorCode.FILTER_E_NO_TEXT);\n            }\n\n            _currentFilter.GetText(ref bufferCharacterCount, pBuffer);\n        }\n\n        /// <summary>\n        /// Gets the property value corresponding to current chunk.\n        /// </summary>\n        /// <returns>Property value</returns>\n        public IntPtr GetValue()\n        {\n            if (_progress != Progress.FilteringCoreProperties)\n            {\n                throw new COMException(SR.FilterGetValueNotSupported,\n                    (int)FilterErrorCode.FILTER_E_NO_VALUES);\n            }\n","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/PackageFilter.cs#L208-L244","documentation":"In the IFilter protocol, a chunk carries either text or property values, never both. PackageFilter.GetText only works while the current chunk is a content (text) chunk (Progress.FilteringContent); otherwise it throws FILTER_E_NO_TEXT (0x80041705) as a COMException, indicating GetText is not valid for the chunk you are on.","triggerScenarios":"Calling GetText while the current chunk is a core-properties chunk (or before any chunk has been fetched / after chunks are exhausted), i.e. whenever _progress != Progress.FilteringContent.","commonSituations":"Indexers that call GetText unconditionally on every chunk instead of checking the chunk's attributes/flags; core-property chunks carry values, so GetText fails on them.","solutions":["Only call GetText when the current chunk represents text content; check the chunk attributes (CHUNKSTATE) returned by GetChunk before calling.","Call GetValue() instead when the chunk is a core-properties chunk.","Catch COMException with HResult 0x80041705 and skip text extraction for that chunk, continuing with the next."],"exampleFix":"// before\nfilter.GetChunk(out chunk);\nfilter.GetText(ref bufCount, pBuffer); // throws on property chunks\n// after\nfilter.GetChunk(out chunk);\nif (chunk.flags == CHUNKSTATE.CHUNK_TEXT)\n    filter.GetText(ref bufCount, pBuffer);\nelse\n    IntPtr v = filter.GetValue(); // property chunk","handlingStrategy":"type-guard","validationCode":"// After GetChunk, only call GetText for content (text) chunks:\nbool canGetText = (chunk.flags & CHUNKSTATE.CHUNK_TEXT) != 0;","typeGuard":"static bool IsTextChunk(System.Runtime.InteropServices.ComTypes.STAT_CHUNK c)\n    => (c.flags & System.Runtime.InteropServices.ComTypes.CHUNKSTATE.CHUNK_TEXT) != 0;","tryCatchPattern":"try { filter.GetText(ref bufCount, pBuffer); }\ncatch (COMException e) when (e.HResult == unchecked((int)0x80041705))\n{ /* FILTER_E_NO_TEXT: current chunk has no text — skip or call GetValue */ }","preventionTips":["Branch on the chunk's CHUNKSTATE attributes returned by GetChunk before extracting.","Call GetText only for CHUNK_TEXT chunks and GetValue only for CHUNK_VALUE chunks.","Keep filter state (current chunk kind) explicit in your indexer loop."],"tags":["ifilter","indexing","wrong-chunk-type"],"backgroundTag":"unsupported-operation","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"}