This project has moved. For the latest updates, please go here.

RichTextBox with RtfFormatter throws System.FormatException on keystrokes

Jul 5 at 8:58 AM
Edited Jul 5 at 11:31 AM
Hey,

i recently started using the Extended WPF Toolkit and noticed when i use the RichTextBox with the RtfFormatter, mscorlib.dll throws a "System.FormatException" on every keystroke. When using the PlainTextFormatter or the XamlFormatter this will not happen. I couldnt track down the reason why this is happening, but it is easy to reproduce (just create a RichTextBox with a RtfFormatter). I don't know if its a bad thing for my application performance when so many exceptions are thrown but it seems wrong. Can someone explain me why this is happening or how to fix it? I would like to save the content of the RichTextBox as an rtf formated string without getting exceptions on every keystroke.

Edit: I debugged the LiveExplorer application and the exception occurs when the TextRange.Save(MemoryStream, string) method is called. After some research i found this ticket from Brian Lagunas https://connect.microsoft.com/VisualStudio/feedback/details/631925/textrange-save-throws-formatexception-when-saving-rtf. It seems there is no fix and i need to live with it.