Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Issue: RichTextBox throws System.FormatException [19857]

$
0
0
With version 2.0, I can no longer initialize a RichTextBox control. I'm probably missing some change to the control, but I cannot see what. It throws a System.FormatException when it needs only to create the control. There is no Text property binding, nothing. See below.

```
<Window x:Class="RichTextBoxX.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:extwpf="http://schemas.xceed.com/wpf/xaml/toolkit"
Title="Extended WPF Toolkit RichTextBox Test" Height="350" Width="525"
>
<Grid>
<extwpf:RichTextBox />
</Grid>
</Window>

```
__MainWindow.xaml.cs:__
```
public MainWindow()
{
InitializeComponent();
DataContext = this;
}

```

__Exception Detail__
System.FormatException occurred
HResult=-2146233033
Message=Input string was not in a correct format.
Source=mscorlib
StackTrace:
at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)
InnerException:

__Stack Trace__
mscorlib.dll!System.Number.ParseDouble(string value, System.Globalization.NumberStyles options, System.Globalization.NumberFormatInfo numfmt) + 0x1dd bytes
mscorlib.dll!System.Convert.ToDouble(string value, System.IFormatProvider provider) + 0x2b bytes
PresentationFramework.dll!System.Windows.Documents.Converters.StringToDouble(string s, ref double d = 0.0) + 0x40 bytes
PresentationFramework.dll!System.Windows.Documents.XamlToRtfWriter.XamlParserHelper.ConvertToLineHeight(System.Windows.Documents.ConverterState converterState, string s, ref double d) + 0xb bytes
PresentationFramework.dll!System.Windows.Documents.XamlToRtfWriter.XamlIn.HandleAttributes(System.Windows.Documents.ConverterState converterState = {System.Windows.Documents.ConverterState}, System.Windows.Documents.IXamlAttributes attributes = {System.Windows.Documents.XamlToRtfParser.XamlAttributes}, System.Windows.Documents.DocumentNode documentNode = {System.Windows.Documents.DocumentNode}, System.Windows.Documents.XamlToRtfWriter.XamlTag xamlTag = XTSection, System.Windows.Documents.DocumentNodeArray dna = Count = 0) + 0xc9e bytes
PresentationFramework.dll!System.Windows.Documents.XamlToRtfWriter.XamlIn.System.Windows.Documents.IXamlContentHandler.StartElement(string nameSpaceUri, string localName, string qName, System.Windows.Documents.IXamlAttributes attributes) + 0xdb bytes
PresentationFramework.dll!System.Windows.Documents.XamlToRtfParser.ParseXTokStartElement(System.Windows.Documents.XamlToRtfParser.XamlToken xamlToken, ref string name = "Section") + 0x49 bytes
PresentationFramework.dll!System.Windows.Documents.XamlToRtfParser.Parse() + 0xa9 bytes
PresentationFramework.dll!System.Windows.Documents.XamlToRtfWriter.Process() + 0x14 bytes
PresentationFramework.dll!System.Windows.Documents.XamlRtfConverter.ConvertXamlToRtf(string xamlContent) + 0x54 bytes
PresentationFramework.dll!System.Windows.Documents.TextEditorCopyPaste.ConvertXamlToRtf(string xamlContent, System.IO.Stream wpfContainerMemory) + 0x4f bytes
PresentationFramework.dll!System.Windows.Documents.TextRangeBase.Save(System.Windows.Documents.ITextRange thisRange, System.IO.Stream stream, string dataFormat, bool preserveTextElements) + 0x16a bytes
PresentationFramework.dll!System.Windows.Documents.TextRange.System.Windows.Documents.ITextRange.Save(System.IO.Stream stream, string dataFormat) + 0xb bytes
PresentationFramework.dll!System.Windows.Documents.TextRange.Save(System.IO.Stream stream, string dataFormat) + 0xc bytes
Xceed.Wpf.Toolkit.dll!Xceed.Wpf.Toolkit.RtfFormatter.GetText(System.Windows.Documents.FlowDocument document = {System.Windows.Documents.FlowDocument}) + 0xb3 bytes
Xceed.Wpf.Toolkit.dll!Xceed.Wpf.Toolkit.RichTextBox.UpdateTextFromDocument() + 0x69 bytes
Xceed.Wpf.Toolkit.dll!Xceed.Wpf.Toolkit.RichTextBox.EndInit() + 0x6c bytes
System.Xaml.dll!MS.Internal.Xaml.Runtime.ClrObjectRuntime.InitializationGuard(System.Xaml.XamlType xamlType = {System.Windows.Baml2006.WpfXamlType}, object obj, bool begin) + 0x44 bytes
System.Xaml.dll!System.Xaml.XamlObjectWriter.Logic_EndInit(MS.Internal.Xaml.Context.ObjectWriterContext ctx) + 0x2a bytes
System.Xaml.dll!System.Xaml.XamlObjectWriter.WriteEndObject() + 0x182 bytes
System.Xaml.dll!System.Xaml.XamlWriter.WriteNode(System.Xaml.XamlReader reader) + 0x58 bytes
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.TransformNodes(System.Xaml.XamlReader xamlReader = {System.Windows.Baml2006.Baml2006Reader}, System.Xaml.XamlObjectWriter xamlWriter = {System.Xaml.XamlObjectWriter}, bool onlyLoadOneNode = false, bool skipJournaledProperties = false, bool shouldPassLineNumberInfo = true, System.Xaml.IXamlLineInfo xamlLineInfo = {System.Windows.Baml2006.Baml2006Reader}, System.Xaml.IXamlLineInfoConsumer xamlLineInfoConsumer = {System.Xaml.XamlObjectWriter}, MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame> stack = {MS.Internal.Xaml.Context.XamlContextStack<System.Windows.Markup.WpfXamlFrame>}, System.Windows.Markup.IStyleConnector styleConnector = null) + 0x2a5 bytes
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader xamlReader, System.Xaml.IXamlObjectWriterFactory writerFactory, bool skipJournaledProperties, object rootObject, System.Xaml.XamlObjectWriterSettings settings, System.Uri baseUri = {System.Uri}) + 0x10f bytes
PresentationFramework.dll!System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader xamlReader = {System.Windows.Baml2006.Baml2006Reader}, bool skipJournaledProperties, object rootObject, System.Xaml.Permissions.XamlAccessLevel accessLevel, System.Uri baseUri) + 0x40 bytes
PresentationFramework.dll!System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream stream = {MS.Internal.AppModel.BamlStream}, System.Windows.Markup.ParserContext parserContext = {System.Windows.Markup.ParserContext}, object parent, bool closeStream = false) + 0x20b bytes
PresentationFramework.dll!System.Windows.Application.LoadComponent(object component, System.Uri resourceLocator) + 0x18f bytes
RichTextBoxX.exe!RichTextBoxX.MainWindow.InitializeComponent() Line 1 + 0xb bytes C#
Comments: ** Comment from web user: JesperRisager **

I ran into the exact same problem.

I think the reason you could not reproduce it is because it is a handled error.

You need to turn "Enable Just My code" off in Options | Debugging | General, to see the error.

In other words it is an eror that is thrown and getting caught and it only seems to give problems when you debug and are enabling debugging of other code than your own.

Still its very anoying.

In my particular case the issue creating the problem was this code:

var range = new TextRange(_outputLogDocument.ContentStart, _outputLogDocument.ContentEnd);

// Save _outputLogDocument with RTF from stream.
range.Save(stream, DataFormats.Rtf);

I databind to the output of this.

MS had a similar issue here:

https://social.msdn.microsoft.com/Forums/vstudio/en-US/8b2c7bbe-961f-4dc7-8057-4180c2a7aeeb/textrangesave-throws-a-formatexception-when-saving-rtf?forum=wpf

seems they decided to not fix it though.


Viewing all articles
Browse latest Browse all 4964

Trending Articles