'WinForms RichTextBox - InvalidOperationException: Cannot load the text - happens only in .Net 6

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?

EDIT:

The code is executed on the same machine, changing .Net versions via Visual Studio

#if !NETCOREAPP
            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;
#endif
#if NETCOREAPP
            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;
#endif  


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source