dotnet/wpf · error · InvalidOperationException
SR.Format(SR.CreateParaBreakingSessionFailure, lserr)
Error message
SR.Format(SR.CreateParaBreakingSessionFailure, lserr)
What it means
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.
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
Example fix
// check inner exception
try { /* format paragraph */ }
catch (InvalidOperationException ex) when (ex.InnerException != null) {
log(ex.InnerException); // exception thrown in your callbacks
} Defensive patterns
Strategy: try-catch
Try / catch
try { /* paragraph formatting */ } catch (InvalidOperationException ex) when (ex.Message.Contains("CreateParaBreakingSessionFailure")) { var root = ex.InnerException ?? ex; log(root); } Prevention
- Fix exceptions thrown inside custom paragraph callbacks (they surface wrapped here)
- Validate tab/paragraph property values before formatting
- Isolate offending text/properties when reproducing
When it happens
Trigger: Constructing TextFormatterImp's paragraph cache when the native LS engine fails during CreateParaBreakingSession, either due to callback exception or an LS error code return.
Common situations: Complex paragraph layouts with custom tab/paragraph properties the LS engine rejects, or exceptions thrown inside ITextParagraph callback implementations.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- message (formatted LS error message, e.g. SR.SetTabsFailure…
- ArgumentNullException("characterBufferReference.CharacterBuf…
- ArgumentNullException("textRunProperties.CultureInfo")
- ArgumentNullException("textRunProperties.Typeface")
- ArgumentNullException("textRunProperties.Typeface")
AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14).
Data as JSON: /api/errors/6df624df1bfa0536.
Report an issue: GitHub.
Appendix: source
Thrown at src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/textformatting/TextParagraphCache.cs:76
// since we handle Bidi break ourselves.
IntPtr.Zero,
ref ploparabreakValue,
ref _penalizedAsJustified
);
// get the exception in context before it is released
Exception callbackException = context.CallbackException;
// release the context
context.Release();
if(lserr != LsErr.None)
{
GC.SuppressFinalize(this);
if(callbackException != null)
{
// rethrow exception thrown in callbacks
throw new InvalidOperationException(SR.Format(SR.CreateParaBreakingSessionFailure, lserr), callbackException);
}
else
{
// throw with LS error codes
TextFormatterContext.ThrowExceptionFromLsError(SR.Format(SR.CreateParaBreakingSessionFailure, lserr), lserr);
}
}
_ploparabreak = ploparabreakValue;
// keep context alive till here
GC.KeepAlive(context);
}
/// <summary>
/// Finalizing paragraph content cache
/// </summary>View on GitHub (pinned to 81131a70a4)