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.

ArgumentOutOfRangeException TextBlock

See original GitHub issue

I wasn’t able to repro it, but sometimes the start parameter is bigger than the length of the actual string, causing this exception. @Gillibald Any idea why this is happening? Thanks

Update Seems like it happens only with Segoe UI font (maybe due to it taking more space than default?) Repro -

<TextBlock
            DockPanel.Dock="Top"
            HorizontalAlignment="Center"
            TextAlignment="Left"
            Margin="0,0,0,6"
            FontSize="14"
            MaxLines="3"
            FontFamily="Segoe UI"
            FontWeight="DemiBold"
            TextWrapping="Wrap"
            MaxWidth="320"
            Text="www.htzone.co.il - מועדון הצרכנות של ההייטקיסטים and 5 more pages - Personal - Microsoft​ Edge" />

Application: fluentsearch.exe CoreCLR Version: 5.0.20.47505 .NET Version: 5.0.0-rc.2.20475.5 Description: The process was terminated due to an unhandled exception. Exception Info: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. (Parameter ‘start’) 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.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 Blast.Program.Main(String[] args) in C:\Users\adirh\RiderProjects\Blast\Blast\Program.cs:line 85

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
Gillibaldcommented, Oct 8, 2020

Thanks for all the details. Helps a lot to fix this. Having a look asap.

0reactions
Gillibaldcommented, Feb 18, 2021

The crash is fixed. The RTL text wrapping has its own issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TextBlock TextFormatting ArgumentOutOfRangeException
When displaying some strings in TextBlock I am getting the exception below. I will update here once I find the problematic string.
Read more >
ArgumentOutOfRangeException.Message Property (System)
The text message for this exception. The value of this property takes one of two forms, as follows. Condition, Value. The actualValue is ......
Read more >
Why do I get a 'System.ArgumentOutOfRangeException ...
The problem with this line: e.Row.Cells[3].Text = count;. Appears to be that this row does not have 4 cells. Check it by putting...
Read more >
Index was out of range problem, Creating text
ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
Read more >
Regex leads to ArgumentOutOfRangeException in ...
ArgumentOutOfRangeException : Specified argument was out of the range of valid values. Parameter name: span at Microsoft.VisualStudio.Text.
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