dotnet/wpf · error · COMException
FILTER_E_ACCESS
FILTER_E_ACCESS
Error message
File to filter is not loaded.
What it means
COMException from XpsFilter's IFilter.GetChunk: the inner filter object is null because Init/IPersistFile::Load was never completed, so there is no loaded file to enumerate chunks from; the error is returned as FILTER_E_ACCESS with the 'file not loaded' message.
Solutions
- Call IPersistFile.Load before GetChunk
- Verify Load succeeded and restart the chunk loop
- Skip the file and log when the filter cannot be loaded
Example fix
// before var chunk = ((IFilter)filter).GetChunk(); // after if (!loaded) ((IPersistFile)filter).Load(path, STGM.READ); var chunk = ((IFilter)filter).GetChunk();
Defensive patterns
Strategy: try-catch
Try / catch
try { chunk = ((IFilter)filter).GetChunk(); }
catch (COMException ex) when ((uint)ex.ErrorCode == 0x80041200 || ex.ErrorCode == unchecked((int)0x80004005)) { /* skip file or reload */ } Prevention
- Enforce Load-then-use ordering in a wrapper class
- Check Load success before starting chunk enumeration
- Dispose or reset filter instances on failure
When it happens
Trigger: Calling IFilter.GetChunk() on an XpsFilter before IPersistFile.Load has populated the inner filter.
Common situations: Indexers iterating GetChunk/GetText loops on a filter instance whose Load step failed or was skipped.
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
- E_FAIL
- E_INVALIDARG
- E_NOTIMPL
- Buffer address passed to GetText cannot be NULL.
- PrintingCanceledException
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/0aa18d9c96fd4bae.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/IO/Packaging/XpsFilter.cs:76
if (cAttributes > 0 && aAttributes == null)
{
// Attributes count and array do not match.
throw new COMException(SR.FilterInitInvalidAttributes,
(int)NativeMethods.E_INVALIDARG);
}
return _filter.Init(grfFlags, cAttributes, aAttributes);
}
/// <summary>
/// Returns description of the next chunk.
/// </summary>
/// <returns>Chunk descriptor</returns>
STAT_CHUNK IFilter.GetChunk()
{
if (_filter == null)
{
throw new COMException(SR.FileToFilterNotLoaded,
(int)FilterErrorCode.FILTER_E_ACCESS);
}
try
{
return _filter.GetChunk();
}
catch (COMException ex)
{
// End-of-data? If so, release the package.
if (ex.ErrorCode == (int)FilterErrorCode.FILTER_E_END_OF_CHUNKS)
ReleaseResources();
throw;
}
}
/// <summary>View on GitHub (pinned to 81131a70a4)