我有一个 RichEditBox,其内容设置为一个文件。很少,在调用该方法时,它会丢弃此异常:
System.AccessViolationException: '试图读取或写入受保护的内存。这通常表明其他内存已损坏。'
这是代码:
var RAS = await TXTFile.OpenAsync(FileAccessMode.ReadWrite);
RTB.Document.LoadFromStream(TextSetOptions.FormatRtf, RAS);
可以通过使用 DispatcherTimer 快速连续调用该方法来重现此错误,但应用程序必须运行大约 10 或 15 分钟才能发生。