首页 > 解决方案 > RichTextBox.RTF 设置器抛出 System.ArgumentException。文件格式在 Windows 版本 1803 中无效

问题描述

模拟以下场景重现崩溃:

  1. 启用Beta:unicode UTF-8 以支持全球语言(启用开始 => 区域和语言设置 => 相关设置 -> 其他日期、时间和区域设置 => 区域 -> 更改日期、时间或数字格式 => 选择管理选项卡 => 单击更改系统区域设置。
  2. Check Beta: unicode UTF-8 for worldwide language support 复选框
  3. 重启系统
  4. 在 Windows 窗体 Application => 添加窗体、RichTextBox、Button 和标签 OnButtonClick => 添加以下行

    richTextBox1.SelectAll();
    richTextBox1.Rtf = richTextBox1.SelectedRtf; //Leads Crash System.ArgumentException: File format is not valid.
    label1.Text = "RichTextBox1.Rtf = " + richTextBox1.Rtf;
    
  5. 如果我们取消选中 Beta: unicode UTF-8 for worldwide language support,然后重新启动系统就没有问题了。

Windows 版本 1803 出现问题

对此用例的任何帮助表示赞赏

标签: windowsversionrichtextboxargumentexception

解决方案


这也是 microsoft build 1803 和 1809 的问题。可以在此处找到解决方案。

https://developercommunity.visualstudio.com/content/problem/544623/issue-caused-by-unicode-utf-8-for-world-wide-langu.html


推荐阅读