dotnet/wpf · warning · COMException

0x80041706

0x80041706

Error message

GetValue operation is not supported on current chunk.

What it means

Mirror of GetText: IFilter chunks carry either text or values. PackageFilter.GetValue only works while the current chunk is a core-properties chunk (Progress.FilteringCoreProperties); otherwise it throws FILTER_E_NO_VALUES (0x80041706) as a COMException, meaning the current chunk has no property value to retrieve.

Solutions

  1. Call GetValue only for core-properties chunks; inspect the chunk attributes returned by GetChunk first.
  2. Use GetText for content chunks and GetValue for property chunks, branching on chunk type.
  3. Catch COMException with HResult 0x80041706 and skip value extraction for that chunk.

Example fix

// before
filter.GetChunk(out chunk);
IntPtr val = filter.GetValue(); // throws on text chunks
// after
filter.GetChunk(out chunk);
if (chunk.flags == CHUNKSTATE.CHUNK_VALUE)
    IntPtr val = filter.GetValue();
else
    filter.GetText(ref bufCount, pBuffer); // content chunk
Defensive patterns

Strategy: type-guard

Validate before calling

// After GetChunk, only call GetValue for property chunks:
bool canGetValue = (chunk.flags & CHUNKSTATE.CHUNK_VALUE) != 0;

Type guard

static bool IsValueChunk(System.Runtime.InteropServices.ComTypes.STAT_CHUNK c)
    => (c.flags & System.Runtime.InteropServices.ComTypes.CHUNKSTATE.CHUNK_VALUE) != 0;

Try / catch

try { IntPtr v = filter.GetValue(); }
catch (COMException e) when (e.HResult == unchecked((int)0x80041706))
{ /* FILTER_E_NO_VALUES: current chunk has no value — skip or call GetText */ }

Prevention

When it happens

Trigger: Calling GetValue() while the current chunk is a plain text/content chunk, or before GetChunk has produced a core-properties chunk.

Common situations: Indexers extracting document metadata (title, author, keywords) that call GetValue on every chunk rather than only on property chunks.

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


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/ed2fce33574fa8e8. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/PackageFilter.cs:241

        {
            if (_progress != Progress.FilteringContent)
            {
                throw new COMException(SR.FilterGetTextNotSupported, 
                    (int)FilterErrorCode.FILTER_E_NO_TEXT);
            }

            _currentFilter.GetText(ref bufferCharacterCount, pBuffer);
        }

        /// <summary>
        /// Gets the property value corresponding to current chunk.
        /// </summary>
        /// <returns>Property value</returns>
        public IntPtr GetValue()
        {
            if (_progress != Progress.FilteringCoreProperties)
            {
                throw new COMException(SR.FilterGetValueNotSupported,
                    (int)FilterErrorCode.FILTER_E_NO_VALUES);
            }

            return _currentFilter.GetValue();
        }

        /// <summary>
        /// BindRegion
        /// </summary>
        /// <param name="origPos"></param>
        /// <param name="riid"></param>
        /// <remarks>
        /// The MSDN specification requires this function to return E_NOTIMPL for the time being.
        /// </remarks>
        public IntPtr BindRegion(FILTERREGION origPos, ref Guid riid)
        {
            throw new NotImplementedException(SR.FilterBindRegionNotImplemented);
        }

View on GitHub (pinned to 81131a70a4)