{"record":{"id":"ac387297b22b5872","repo":"dotnet/wpf","slug":"sr-isfoperationfailed","errorCode":null,"errorMessage":"SR.IsfOperationFailed","messagePattern":"SR\\.IsfOperationFailed","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs","lineNumber":133,"sourceCode":"                    else\n                    {\n                        DecodeRawISF(ms);\n                    }\n                }\n                else if (isGif)\n                {\n                    DecodeRawISF(SystemDrawingHelper.GetCommentFromGifStream(inkData));\n                }\n                else\n                {\n                    DecodeRawISF(inkData);\n                }\n            }\n#if DEBUG\n            catch (ArgumentException ex)\n            {\n                //only include an inner exception in debug builds\n                throw new ArgumentException(SR.IsfOperationFailed, ex);\n            }\n            catch (InvalidOperationException ex)\n            {\n                //only include an inner exception in debug builds\n                throw new ArgumentException(SR.IsfOperationFailed, ex);\n            }\n            catch (IndexOutOfRangeException ex)\n            {\n                //only include an inner exception in debug builds\n                throw new ArgumentException(SR.IsfOperationFailed, ex);\n            }\n            catch (NullReferenceException ex)\n            {\n                //only include an inner exception in debug builds\n                throw new ArgumentException(SR.IsfOperationFailed, ex);\n            }\n            catch (EndOfStreamException ex)\n            {","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/Ink/InkSerializedFormat/InkSerializer.cs#L115-L151","documentation":"DecodeISF is the top-level ISF deserializer; in DEBUG builds it catches ArgumentException from the decoding pipeline and rethrows ArgumentException(SR.IsfOperationFailed) with the original exception as InnerException. The message is intentionally generic - the real cause is in the inner exception (e.g. a bad guid tag, bad huffman data, or other malformed ISF content).","triggerScenarios":"Calling StrokeCollection(ISF stream) / DecodeAsISF on a stream that causes any ArgumentException inside decoding - e.g. a tag outside the known guid range, invalid transforms, or bad compressed data.","commonSituations":"Loading .isf files saved by other apps, deserializing clipboard ink (CF_INK_SERIALIZED_FORMAT), consuming user-uploaded ink payloads.","solutions":["Inspect ex.InnerException (DEBUG builds) to find the root cause.","Validate the stream is a complete, well-formed ISF payload (header check) before decoding.","Regenerate/re-export the ISF data from the originating application.","Catch ArgumentException around StrokeCollection construction and show a generic 'invalid ink data' message to users."],"exampleFix":"// before\nStrokeCollection sc = new StrokeCollection(isfStream); // throws IsfOperationFailed\n// after\ntry { StrokeCollection sc = new StrokeCollection(isfStream); }\ncatch (ArgumentException ex)\n{\n    Log(ex.InnerException ?? ex); // root cause in DEBUG builds\n    sc = new StrokeCollection(); // fallback empty\n}","handlingStrategy":"try-catch","validationCode":"bool LooksLikeIsf(Stream s) { var hdr = new byte[16]; int n = s.Read(hdr,0,16); s.Position=0; return n==16 && hdr[0]==KnownIdCache.IsfHeaderFirstByte; }","typeGuard":null,"tryCatchPattern":"try { strokes = new StrokeCollection(isfStream); }\ncatch (ArgumentException ex) { Log(ex.InnerException ?? ex); ShowInvalidInkMessage(); }","preventionTips":["Validate the ISF header before constructing a StrokeCollection","Only deserialize ISF from trusted origins","Always inspect InnerException when debugging IsfOperationFailed"],"tags":["ink","isf","deserialization","argument-exception"],"backgroundTag":"invalid-argument-format","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"}