One of my customers tried to load a document into an application I developed for them that uses the RadRichTextBox and they received the following exception. The document can not be attached but I found a document on the internet that causes the same result:
- Document: http://ecn.channel9.msdn.com/o9/learn/Silverlight4/Labs/RichTextBox/RichTextBox%20Lab.docx
Basically, I don't need the document to load (although that would be nice), I just need the RadRichTextBox to not exploded. You know, for stability's sake.
Message: Unhandled Error in Silverlight Application
Code: 4004
Category: ManagedRuntimeError
Message: System.InvalidCastException: Unable to cast object of type 'Telerik.Windows.Documents.Model.BookmarkRangeStart' to type 'Telerik.Windows.Documents.Model.AnnotationRangeEnd'.
at Telerik.Windows.Documents.Model.RadDocument.PairAnnotationRanges(IEnumerable`1 annotationMarkers)
at Telerik.Windows.Documents.Model.RadDocument.PairAnnotationRanges()
at Telerik.Windows.Documents.Layout.DocumentLayoutBox.UpdateGlobalProperties()
at Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverride(SizeF availableSize)
at Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(SizeF availableSize)
at Telerik.Windows.Documents.Layout.LayoutElement.Measure(SizeF availableSize)
at Telerik.Windows.Documents.Model.RadDocument.Measure(SizeF measureSize)
at Telerik.Windows.Documents.UI.DocumentPrintLayoutPresenter.MeasureOverride(Size availableSize)
at System.Windows.FrameworkElement.MeasureOverride(IntPtr nativeTarget, Single inWidth, Single inHeight, Single& outWidth, Single& outHeight)
Line: 120
Char: 13
Code: 0
URI: http://localhost:6519/
5 Answers, 1 is accepted
Thank you for getting to us about this bug. Our policy is to try and import documents with minimal loss (if there are document elements that go beyond the supported ones in RadDocument). In case the import is unsuccessful, a MessageBox should be shown. There are rare cases when the document is supposedly imported properly and a problem occurs afterwards.
We will look into the import and provide a fix in the next release (Q2 2011 Beta), which is due in mid-June at latest.
We are sorry for he inconvenience caused. Your Telerik points have been updated in appreciation for the bug report.
Iva
the Telerik team
I'm just following up on this. I have the Q2 release, but still get this error.
Can you please have a look at my code to see if I did something wrong?
RadDocument
doc = new RadDocument();
IDocumentFormatProvider provider = DocumentFormatProvidersManager.GetProviderByExtension(extension);
if (provider != null)
{
doc = provider.Import(stream);
}
else
{
MessageBox.Show("Unknown format.");
return;
}
//Get Error Here!!
doc.Measure(
RadDocument.MAX_DOCUMENT_SIZE);
doc.Arrange(
new RectangleF(PointF.Empty, doc.DesiredSize));
//
doc.LayoutMode =
DocumentLayoutMode.Paged;
doc.DefaultPageLayoutSettings.Width = 320/0.4F;
doc.DefaultPageLayoutSettings.Height = 390/0.35F;
doc.SectionDefaultPageMargin =
new Padding(20);
doc.Sections.First.PageMargin =
new Padding(20);
//Get Error Here!!
doc.UpdateLayout();
this.book.RightPageIndex = 0;
 
this.viewManager.Document = doc;
bindingSource.Document = doc;
Thanks
Jerrica
Best wishes,
Ivailo
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
string
radTextBoxXaml = @"<tCtr:RadRichTextBox xmlns=
'http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:tCtr=
'clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents'
IsSelectionMiniToolBarEnabled=
'False'
IsContextMenuEnabled=
'False'
IsSpellCheckingEnabled=
'False'
IsReadOnly=
'True'
LayoutMode=
'Flow'
BorderThickness=
'0'
Padding=
'0'
BorderBrush=
'Transparent'
HorizontalScrollBarVisibility=
'Disabled'
HyperlinkNavigationMode=
'Click'
><t:RadDocument xmlns=
'http://schemas.microsoft.com/winfx/2006/xaml/presentation'
xmlns:t=
'clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents'
DefaultPageLayoutSettings=
'816,1056'
LayoutMode=
'Flow'
PageViewMargin=
'10,10'
>
<t:RadDocument.Lists>
<t:ListSerializationData ID=
'1'
StyleID=
'1'
/>
<t:ListSerializationData ID=
'2'
StyleID=
'2'
/>
<t:ListSerializationData ID=
'3'
StyleID=
'3'
/>
</t:RadDocument.Lists>
<t:RadDocument.ListStyles>
<t:ListStyle ID=
'1'
>
<t:ListLevelStyle LevelText=
'{}{0}.'
NumberingFormat=
'Decimal'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{1}.'
NumberingFormat=
'LowerLetter'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{2}.'
NumberingFormat=
'LowerRoman'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{3}.'
NumberingFormat=
'Decimal'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{4}.'
NumberingFormat=
'LowerLetter'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{5}.'
NumberingFormat=
'LowerRoman'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{6}.'
NumberingFormat=
'Decimal'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{7}.'
NumberingFormat=
'LowerLetter'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{8}.'
NumberingFormat=
'LowerRoman'
StartingIndex=
'1'
/>
</t:ListStyle>
<t:ListStyle ID=
'2'
>
<t:ListLevelStyle FontFamily=
'Symbol'
LevelText=
'?'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Courier New'
LevelText=
'o'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Wingdings'
LevelText=
'?'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Symbol'
LevelText=
'?'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Courier New'
LevelText=
'o'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Wingdings'
LevelText=
'?'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Symbol'
LevelText=
'?'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Courier New'
LevelText=
'o'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
<t:ListLevelStyle FontFamily=
'Wingdings'
LevelText=
'?'
NumberingFormat=
'Bullet'
StartingIndex=
'1'
/>
</t:ListStyle>
<t:ListStyle ID=
'3'
>
<t:ListLevelStyle LevelText=
'{}{0})'
NumberingFormat=
'Decimal'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{1})'
NumberingFormat=
'LowerLetter'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{2})'
NumberingFormat=
'LowerRoman'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{3})'
NumberingFormat=
'Decimal'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{4})'
NumberingFormat=
'LowerLetter'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{5})'
NumberingFormat=
'LowerRoman'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{6})'
NumberingFormat=
'Decimal'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{7})'
NumberingFormat=
'LowerLetter'
StartingIndex=
'1'
/>
<t:ListLevelStyle LevelText=
'{}{8})'
NumberingFormat=
'LowerRoman'
StartingIndex=
'1'
/>
</t:ListStyle>
</t:RadDocument.ListStyles>
<t:Section>
<t:Paragraph>
<t:Paragraph.ListItemSerializationData>
<t:ListItemSerializationData ListID=
'1'
ListLevel=
'0'
/>
</t:Paragraph.ListItemSerializationData>
<t:Span FontFamily=
'Verdana'
FontSize=
'16'
Text=
'sdfg sdfg sdfg'
UnderlineColor=
'#FF000000'
UnderlineDecoration=
'None'
/>
</t:Paragraph>
<t:Paragraph>
<t:Paragraph.ListItemSerializationData>
<t:ListItemSerializationData ListID=
'2'
ListLevel=
'0'
/>
</t:Paragraph.ListItemSerializationData>
<t:Span FontFamily=
'Verdana'
FontSize=
'16'
Text=
'sdfgs'
UnderlineColor=
'#FF000000'
UnderlineDecoration=
'None'
/>
</t:Paragraph>
<t:Paragraph>
<t:Paragraph.ListItemSerializationData>
<t:ListItemSerializationData ListID=
'3'
ListLevel=
'0'
/>
</t:Paragraph.ListItemSerializationData>
<t:Span FontFamily=
'Verdana'
FontSize=
'16'
Text=
'sdfg'
UnderlineColor=
'#FF000000'
UnderlineDecoration=
'None'
/>
</t:Paragraph>
</t:Section>
</t:RadDocument></tCtr:RadRichTextBox>";
var tb = (Telerik.Windows.Controls.RadRichTextBox)XamlReader.Load(radTextBoxXaml);
this
.LayoutRoot.Children.Add(tb);
// after this method returns, the UI freezes
Below is the stack trace I obtained by Pausing my application in the Debugger and openning the "Debug->Windows->Threads" window
ThreadID = 2448
ManagedID = 1
Cagegory = Main Thread
Name = Main Thread
Priority = Normal
Location = Telerik.Windows.Documents.Model.Paragraph.FlowDirection.get()
Telerik.Windows.Documents!Telerik.Windows.Documents.Model.Paragraph.FlowDirection.get() + 0x32 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.ParagraphLayoutBox.MeasureOverride.AnonymousMethod__0() + 0x74 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.ParagraphLayoutBox.MeasureOverride(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x1adf bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x557 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.LayoutElement.Measure(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x389 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverrideInternal(Telerik.Windows.Documents.Model.SizeF availableSize) + 0xa5d bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.SectionLayoutBox.MeasureOverride(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x11b bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x557 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.LayoutElement.Measure(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x389 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.DocumentLayoutBox.MeasureOverride(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x460 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.LayoutElement.MeasureCore(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x557 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Layout.LayoutElement.Measure(Telerik.Windows.Documents.Model.SizeF availableSize) + 0x389 bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.Model.RadDocument.Measure(Telerik.Windows.Documents.Model.SizeF measureSize) + 0x7e bytes
Telerik.Windows.Documents!Telerik.Windows.Documents.UI.DocumentWebLayoutPresenter.MeasureOverride(System.Windows.Size availableSize) + 0x378 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0xa3 bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0xa3 bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0xa3 bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0xa3 bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0xa3 bytes
[Managed to Native Transition]
System.Windows.dll!MS.Internal.XcpImports.FrameworkElement_MeasureOverride(System.Windows.FrameworkElement element, System.Windows.Size availableSize) + 0x62 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.Windows.Size availableSize) + 0x18 bytes
System.Windows.dll!System.Windows.FrameworkElement.MeasureOverride(System.IntPtr nativeTarget, float inWidth, float inHeight, out float outWidth, out float outHeight) + 0xa3 bytes
[Appdomain Transition]
We are sorry to hear you are experiencing issues with RadRichTextBox. As for requesting code-samples and demos, we are only doing that as a last resort when we have not managed to reproduce the issue in a sample project of ours following the steps you have listed. It's all for the sake of resolving the problem you have encountered.
I am afraid you might not be happy about this answer either. I have tried the exact code you have posted with the latest version of the control and were not able to reproduce the UI freeze. Please find attached the application I have created.
The only possible cause that comes to mind (even though it is a long shot, provided that I could not reproduce the issue) is that you are using an older version of the controls or another version of Silverlight. You should have in mind that Silverlight 5 has not been officially released yet and is not supported for now.
Iva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>