dotnet/wpf · error · COMException

0x80041702

0x80041702

Error message

GetValue was already called on current chunk.

What it means

CorePropertiesFilter returns at most one property value per chunk, tracked by the _pendingGetValue flag. A second GetValue() call on the same chunk (before a new successful GetChunk) throws a COMException with FILTER_E_NO_MORE_VALUES (0x80041702), per IFilter protocol.

Solutions

  1. Call GetValue() at most once per chunk; call GetChunk() to advance before the next GetValue().
  2. Model the loop as: GetChunk -> if value chunk, GetValue once -> repeat.
  3. Catch COMException with HResult 0x80041702 and treat it as end-of-values for the current chunk.

Example fix

// before
object v1 = filter.GetValue();
object v2 = filter.GetValue(); // throws
// after
object v1 = filter.GetValue();
if (filter.GetChunk() == FILTER_E_END_OF_CHUNKS) break;
object v2 = filter.GetValue();
Defensive patterns

Strategy: validation

Validate before calling

bool valuePending = true; // set true after GetChunk, set false after first GetValue
if (!valuePending) throw new InvalidOperationException("GetValue already consumed for this chunk");

Try / catch

try { value = filter.GetValue(); pending = false; } catch (COMException ex) when (ex.HResult == unchecked((int)0x80041702)) { /* already consumed: call GetChunk next */ }

Prevention

When it happens

Trigger: Calling GetValue() twice on the current chunk without an intervening GetChunk() call.

Common situations: Looping 'while true { GetValue() }' expecting multiple values per chunk; retry logic that re-calls GetValue after a partial failure; misunderstanding the IFilter one-value-per-chunk contract.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/CorePropertiesFilter.cs:143

        /// <returns></returns>
        /// <remarks>Not supported in indexing of core properties.</remarks>
        public string GetText(int bufferCharacterCount)
        {
            throw new COMException(SR.FilterGetTextNotSupported,
                (int)FilterErrorCode.FILTER_E_NO_TEXT);
        }

        /// <summary>
        /// Gets the property value corresponding to current chunk.
        /// </summary>
        /// <returns>Property value</returns>
        public object GetValue()
        {
            // If GetValue() is already called for current chunk,
            // return error with FILTER_E_NO_MORE_VALUES.
            if (!_pendingGetValue)
            {
                throw new COMException(SR.FilterGetValueAlreadyCalledOnCurrentChunk,
                    (int)FilterErrorCode.FILTER_E_NO_MORE_VALUES);
            }

            // No GetValue() call pending from this point on
            // until another call to GetChunk() is made successfully.
            _pendingGetValue = false;

            return CorePropertyEnumerator.CurrentValue;
        }

        #endregion IManagedFilter methods

        #region Private methods

        /// <summary>
        /// Generates unique and legal chunk ID.
        /// To be called prior to returning a chunk.
        /// </summary>

View on GitHub (pinned to 81131a70a4)