dotnet/wpf · error · ArgumentOutOfRangeException

ArgumentOutOfRangeException

Error message

ArgumentOutOfRangeException

What it means

ArgumentOutOfRangeException thrown by CheckedPointer.ToArray when the unsafe native pointer is null — i.e. the memory-mapped font cache view was never initialized, so there is nothing to copy into the byte array. The argument at fault is the internal _pointer, not a caller-supplied value.

Solutions

  1. Ensure the CheckedPointer was successfully created from a valid font cache mapping before calling ToArray
  2. Check the pointer for null (or IsNull) before calling ToArray and handle the uninitialized case explicitly
  3. Reopen the font cache mapping and retry the copy
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs:73 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs:73

                }
            }
        }

        internal int Size
        {
            get
            {
                return _size;
            }
        }

        internal byte[] ToArray()
        {
            byte[] b = new byte[_size];
            unsafe
            {
                if (_pointer == null)
                    throw new ArgumentOutOfRangeException();

                Marshal.Copy((IntPtr)_pointer, b, 0, Size);
            }
            return b;
        }

        internal void CopyTo(CheckedPointer dest)
        {
            unsafe
            {
                if (_pointer == null)
                    throw new ArgumentOutOfRangeException();

                byte* s = (byte*)_pointer;
                byte * d = (byte *)dest.Probe(0, _size);
                for (int i = 0; i < _size; ++i)
                {
                    d[i] = s[i];

View on GitHub (pinned to 81131a70a4)