To use this form of \ud, try adding \uc0 (after \ansi, for example).
WinForms RichTextBox - InvalidOperationException: Cannot load the text - happens only in .Net 6
WPF-Learner
106
Reputation points
I'm using System.Windows.Forms.RichTextBox, and have the following code:
var testRichTextBox = new System.Windows.Forms.RichTextBox();
var testText = @"{\rtf1\ansi\deff0{\fonttbl{\f0 Courier New;}}{\colortbl\red0\green0\blue0;}\fs20{\cf0 \ud{\u160}}\line }";
testRichTextBox.Rtf = testText;
This same code works perfectly in .Net 4.7.2.
When trying to run it in .Net 6, the following exception is produced:
System.InvalidOperationException: Cannot load the text.
at System.Windows.Forms.RichTextBox.StreamIn(Stream data, SF flags)
at System.Windows.Forms.RichTextBox.StreamIn(String str, SF flags)
at System.Windows.Forms.RichTextBox.set_Rtf(String value)
Couldn't find any documentation about it in the WinForms breaking changes in .Net 6 on MSDN, what can be the cause for that?