{"record":{"id":"6df624df1bfa0536","repo":"dotnet/wpf","slug":"sr-format-sr-createparabreakingsessionfailure-lserr","errorCode":null,"errorMessage":"SR.Format(SR.CreateParaBreakingSessionFailure, lserr)","messagePattern":"SR\\.Format\\(SR\\.CreateParaBreakingSessionFailure, lserr\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs","lineNumber":76,"sourceCode":"                // since we handle Bidi break ourselves.\n                IntPtr.Zero,\n                ref ploparabreakValue,\n                ref _penalizedAsJustified\n                );\n\n            // get the exception in context before it is released\n            Exception callbackException = context.CallbackException;\n            \n            // release the context\n            context.Release();\n\n            if(lserr != LsErr.None)\n            {\n                GC.SuppressFinalize(this);\n                if(callbackException != null)\n                {                        \n                    // rethrow exception thrown in callbacks\n                    throw new InvalidOperationException(SR.Format(SR.CreateParaBreakingSessionFailure, lserr), callbackException);\n                }\n                else\n                {\n                    // throw with LS error codes\n                    TextFormatterContext.ThrowExceptionFromLsError(SR.Format(SR.CreateParaBreakingSessionFailure, lserr), lserr);\n                }\n            }\n\n            _ploparabreak = ploparabreakValue;\n\n            // keep context alive till here\n            GC.KeepAlive(context);\n        }\n\n\n        /// <summary>\n        /// Finalizing paragraph content cache\n        /// </summary>","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs#L58-L94","documentation":"During creation of the paragraph-breaking session in the TextParagraphCache constructor, an LS error (lserr != LsErr.None) surfaced. If an exception was thrown inside the native callbacks, it is wrapped in an InvalidOperationException with that inner exception; otherwise ThrowExceptionFromLsError throws carrying the formatted CreateParaBreakingSessionFailure message. This means the line-services paragraph-breaking session could not be established.","triggerScenarios":"Constructing TextFormatterImp's paragraph cache when the native LS engine fails during CreateParaBreakingSession, either due to callback exception or an LS error code return.","commonSituations":"Complex paragraph layouts with custom tab/paragraph properties the LS engine rejects, or exceptions thrown inside ITextParagraph callback implementations.","solutions":["Inspect the InnerException (InvalidOperationException case) for the exception thrown in your callbacks","Fix bugs in custom ITextParagraph/TextSource callback implementations","Verify paragraph properties (tabs, indents) are valid and consistent","If purely an lserr with no inner exception, treat as internal line-engine failure and isolate the text that triggers it"],"exampleFix":"// check inner exception\ntry { /* format paragraph */ }\ncatch (InvalidOperationException ex) when (ex.InnerException != null) {\n    log(ex.InnerException); // exception thrown in your callbacks\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* paragraph formatting */ } catch (InvalidOperationException ex) when (ex.Message.Contains(\"CreateParaBreakingSessionFailure\")) { var root = ex.InnerException ?? ex; log(root); }","preventionTips":["Fix exceptions thrown inside custom paragraph callbacks (they surface wrapped here)","Validate tab/paragraph property values before formatting","Isolate offending text/properties when reproducing"],"tags":["wpf","textformatting","linelayout","callback"],"backgroundTag":"internal-invariant-violation","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"}