I get a NotSupported exception on tr.Save below:
Exception thrown: 'System.NotSupportedException' in PresentationCore.dll
Additional information: BitmapMetadata is not available on BitmapImage.
This happens if i copy and paste text and a pic from a word docx to the richtextbox
(named rtbEditor in the code below) and then try to retrieve the text
with the code below. This so far seems to bve a 'friendly' error in that code execution
continues, and if i store that rtf string, get it again, and send it to the richtextbox
, the image does display. I'll also mention that it is a wpf richtextbox used in a winforms app,
in case that matters. All that said, i'd really like to avoid 'friendly' errors, because they make
debugging real errors more difficult than necessary. TIA for any help :]
Exception thrown: 'System.NotSupportedException' in PresentationCore.dll
Additional information: BitmapMetadata is not available on BitmapImage.
This happens if i copy and paste text and a pic from a word docx to the richtextbox
(named rtbEditor in the code below) and then try to retrieve the text
with the code below. This so far seems to bve a 'friendly' error in that code execution
continues, and if i store that rtf string, get it again, and send it to the richtextbox
, the image does display. I'll also mention that it is a wpf richtextbox used in a winforms app,
in case that matters. All that said, i'd really like to avoid 'friendly' errors, because they make
debugging real errors more difficult than necessary. TIA for any help :]
public string Rtf
{
get
{
TextRange tr = new TextRange(rtbEditor.Document.ContentStart, rtbEditor.Document.ContentEnd);
string stext = null;
using (MemoryStream ms = new MemoryStream())
{
tr.Save(ms, DataFormats.Rtf);
stext = ASCIIEncoding.Default.GetString(ms.ToArray());
}
return stext;
}}