question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextBlock TextFormatting ArgumentOutOfRangeException

See original GitHub issue

When displaying some strings in TextBlock I am getting the exception below. I will update here once I find the problematic string.

Exception Info: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ‘length’) at Avalonia.Utilities.ReadOnlySlice1.Take(Int32 length) at Avalonia.Media.TextFormatting.ShapedTextCharacters.Split(Int32 length) at Avalonia.Media.TextFormatting.TextFormatterImpl.SplitTextRuns(List1 textRuns, Int32 length) at Avalonia.Media.TextFormatting.TextFormatterImpl.PerformTextWrapping(List1 textRuns, TextRange textRange, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak currentLineBreak) at Avalonia.Media.TextFormatting.TextFormatterImpl.FormatLine(ITextSource textSource, Int32 firstTextSourceIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak) at Avalonia.Media.TextFormatting.TextLayout.UpdateLayout() at Avalonia.Media.TextFormatting.TextLayout..ctor(String text, Typeface typeface, Double fontSize, IBrush foreground, TextAlignment textAlignment, TextWrapping textWrapping, TextTrimming textTrimming, TextDecorationCollection textDecorations, Double maxWidth, Double maxHeight, Double lineHeight, Int32 maxLines, IReadOnlyList1 textStyleOverrides) at Avalonia.Controls.TextBlock.CreateTextLayout(Size constraint, String text) at Avalonia.Controls.TextBlock.get_TextLayout() at Avalonia.Controls.TextBlock.MeasureOverride(Size availableSize) at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) at Avalonia.Layout.Layoutable.Measure(Size availableSize) at Avalonia.Controls.StackPanel.MeasureOverride(Size availableSize) at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) at Avalonia.Layout.Layoutable.Measure(Size availableSize) at Avalonia.Layout.LayoutHelper.MeasureChild(ILayoutable control, Size availableSize, Thickness padding) at Avalonia.Controls.Presenters.ContentPresenter.MeasureOverride(Size availableSize) at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) at Avalonia.Layout.Layoutable.Measure(Size availableSize) at Avalonia.Controls.StackPanel.MeasureOverride(Size availableSize) at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) at Avalonia.Layout.Layoutable.Measure(Size availableSize) at Avalonia.Controls.Presenters.ItemVirtualizer.MeasureOverride(Size availableSize) at Avalonia.Layout.Layoutable.MeasureCore(Size availableSize) at Avalonia.Layout.Layoutable.Measure(Size availableSize) at Avalonia.Layout.LayoutManager.Measure(ILayoutable control) at Avalonia.Layout.LayoutManager.Measure(ILayoutable control) at Avalonia.Layout.LayoutManager.ExecuteMeasurePass() at Avalonia.Layout.LayoutManager.InnerLayoutPass() at Avalonia.Layout.LayoutManager.ExecuteLayoutPass() at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority) at Avalonia.Win32.Win32Platform.WndProc(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& lpmsg) at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken cancellationToken) at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) at Blast.Program.Main(String[] args) in C:\Users\adirh\RiderProjects\Blast\Blast\Program.cs:line 44

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
Gillibaldcommented, Sep 4, 2020

Thanks for investigating the causing string. Will have a look shortly. My guess is that I somehow don’t handle non breaking text that needs to wrap properly.

0reactions
Gillibaldcommented, Oct 19, 2022

Haven’t had any reports of such issue. So I close it for now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF - Text Formatter throws ArgumentOutOfRangeException
The problem is that in some cases the GetTextRun method throws an ArgumentOutOfRangeException in the last return statement with the message: " ...
Read more >
Advanced Text Formatting - WPF .NET Framework
TextFormatter is the WPF text formatting engine and provides services for formatting and breaking text lines. The text formatter can handle ...
Read more >
TextRun Class (System.Windows.Media.TextFormatting)
A text run is a sequence of characters sharing a single property set. Any change to the format, such as font style, foreground...
Read more >
ArgumentOutOfRangeException when calculating ...
The exception occurrs when the tool is started and opens a specific file. It looks like something goes wrong when calculating the character ......
Read more >
Specified argument was out of the range of valid values. ...
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: length at Microsoft.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found