You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
WPF Application FailFast in System.Windows.Controls.TextBoxView.GetFormattedLine when using Hebrew text and non-adorner based text selection #2314
The WPF application is using a Textbox component with the text in Hebrew language. The text contain a combination of text and date and month separated by ‘/’. The application is crashing when the user select the ‘/’ along with the number(i.e. date and month). In Windows 10 1909, with the .Net Framework version 4.8 is the environment where the application is experiencing the crash.
Steps to reproduce:
Create a WPF application.
Use a Textbox with the below properties and text.
TextWrapping="Wrap" FlowDirection="RightToLeft" Margin="10" Text="נסה לסמן את הלוכסן שבין הספרות 07/1997 והתוכנה תקרוס"
(Text Translation: Try to mark the slash between the digits 07/1997 and the software will crash)
Set the window size as below
Height="200" Width="250"
Please the below code, in App.xaml.cs
Startup="Application_Startup"
Run the application and select the text including the '/' in the text using the mouse.
The application will crash in few seconds
Notes:
This does appear to be specific to Hebrew. I was unable to reproduce this with Arabic, which is another RTL language.
RTL doesn't actually matter. You can use the same text and change from RTL to LTR. Still repros.
This is specific to non-adorner selection of text.
We are seeing errors with Latin (English) text as well where we crash in the same code. .NET Framework 4.8 here. We have no way to workaround or catch this exception.
Can anyone from Microsoft advise on how we can at least avoid the crash?
We found a workaround which works for our case. It seems that using bad line information in MeasureOverride can be avoided if you delay when you do a SelectAll and set Focus to the TextBox. We use BeginInvoke at ApplicationIdle priority and it appears that the TextBox has the correct font info for its first MeasureOverride and the crash is avoided.
Activity
jschroedl commentedon Dec 19, 2024
We are seeing errors with Latin (English) text as well where we crash in the same code. .NET Framework 4.8 here. We have no way to workaround or catch this exception.
Can anyone from Microsoft advise on how we can at least avoid the crash?
jschroedl commentedon Dec 19, 2024
We found a workaround which works for our case. It seems that using bad line information in MeasureOverride can be avoided if you delay when you do a SelectAll and set Focus to the TextBox. We use BeginInvoke at ApplicationIdle priority and it appears that the TextBox has the correct font info for its first MeasureOverride and the crash is avoided.