{"record":{"id":"718b8aca49b031b7","repo":"dotnet/wpf","slug":"argumentoutofrangeexception","errorCode":null,"errorMessage":"ArgumentOutOfRangeException","messagePattern":"ArgumentOutOfRangeException","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs","lineNumber":73,"sourceCode":"                }\n            }\n        }\n\n        internal int Size\n        {\n            get\n            {\n                return _size;\n            }\n        }\n\n        internal byte[] ToArray()\n        {\n            byte[] b = new byte[_size];\n            unsafe\n            {\n                if (_pointer == null)\n                    throw new ArgumentOutOfRangeException();\n\n                Marshal.Copy((IntPtr)_pointer, b, 0, Size);\n            }\n            return b;\n        }\n\n        internal void CopyTo(CheckedPointer dest)\n        {\n            unsafe\n            {\n                if (_pointer == null)\n                    throw new ArgumentOutOfRangeException();\n\n                byte* s = (byte*)_pointer;\n                byte * d = (byte *)dest.Probe(0, _size);\n                for (int i = 0; i < _size; ++i)\n                {\n                    d[i] = s[i];","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs#L55-L91","documentation":"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.","triggerScenarios":"Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/FontCache/FontCacheUtil.cs:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the CheckedPointer was successfully created from a valid font cache mapping before calling ToArray","Check the pointer for null (or IsNull) before calling ToArray and handle the uninitialized case explicitly","Reopen the font cache mapping and retry the copy"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}