Hi - since updating my application to 15.1.7 and rolling it out to our customers (we have several hundred sites) we're seeing error reports coming back from users showing a problem with the XtraRichEdit control.
We are using the XtraRichEdit control as an editor for composing emails. The feature which is throwing the exception is when a user tries to insert their email signature, which is just a string of RTF DATA which itself is created using a DevEx XtraRichEdit control.
Here's our code which has not changed and has worked for months without any problem :-
C#DocumentRange InsertSignature(string rtfdata)
{
if (String.IsNullOrEmpty(rtfdata))
return null;
Bookmark sig_bookmark = null;
foreach (Bookmark b in richEditControl1.Document.Bookmarks)
if (b.Name == "bk_signature")
{
sig_bookmark = b;
break;
}
DocumentRange rng = null;
if (sig_bookmark != null)
{
// DID find the "bk_signature" bookmark, so just replace...
DocumentPosition start = sig_bookmark.Range.Start;
richEditControl1.Document.Delete(sig_bookmark.Range);
//richEditControl1.Document.RemoveBookmark(sig_bookmark); // <- turns out that we SHOULDN'T delete the bookmark - just the range
rng = richEditControl1.Document.InsertRtfText(start, rtfdata);
richEditControl1.Document.Bookmarks.Create(rng, "bk_signature");
}
else
{
// didn't find the "bk_signature" bookmark, so just insert...
rng = richEditControl1.Document.InsertRtfText(richEditControl1.Document.CaretPosition, rtfdata);
richEditControl1.Document.Bookmarks.Create(rng, "bk_signature");
}
return rng;
}
Here's the stack trace of the exception being thrown for many (though oddly not all) customers :-
=========================================================
Exception Info: System.Exception
Stack:
at DevExpress.XtraRichEdit.Model.Paragraph.GetParagraphIndex()
at DevExpress.XtraRichEdit.Layout.Column.ContainsParagraphFrame(DevExpress.XtraRichEdit.Model.Paragraph)
at DevExpress.XtraRichEdit.Layout.Column.AddParagraphFrame(DevExpress.XtraRichEdit.Model.Paragraph)
at DevExpress.XtraRichEdit.Layout.Engine.RowsController.EndRowCore(DevExpress.XtraRichEdit.Model.Paragraph, DevExpress.XtraRichEdit.Layout.Engine.ParagraphBoxFormatter)
at DevExpress.XtraRichEdit.Layout.Engine.BoxFormatterStateBase.EndRow()
at DevExpress.XtraRichEdit.Layout.Engine.BoxFormatterStateBase.FinalizeParagraph(DevExpress.XtraRichEdit.Layout.Engine.BoxInfo)
at DevExpress.XtraRichEdit.Layout.Engine.StateRowEmptyBase.FinishParagraphCore(DevExpress.XtraRichEdit.Layout.Engine.BoxInfo, DevExpress.XtraRichEdit.Layout.Engine.FinalizeHandler)
at DevExpress.XtraRichEdit.Layout.Engine.StateRowEmptyBase.FinishParagraph()
at DevExpress.XtraRichEdit.Layout.Engine.StateRowEmptyBase.ContinueFormat()
at DevExpress.XtraRichEdit.Layout.Engine.StateParagraphStart.ContinueFormat()
at DevExpress.XtraRichEdit.Layout.Engine.ParagraphBoxFormatter.FormatNextRow()
at DevExpress.XtraRichEdit.Layout.Engine.ContinueParagraphFormatting.FormatNextRow()
at DevExpress.XtraRichEdit.Layout.Engine.DocumentFormatter.FormatNextRow()
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.PerformPrimaryLayoutCore()
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.PerformPrimaryLayout()
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.PerformSecondaryLayout()
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.HandleCommand(Int32)
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.HandleCommand(System.WeakReference, Int32)
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.WorkerBody(System.WeakReference)
at DevExpress.XtraRichEdit.Layout.Engine.BackgroundFormatter.Worker(System.Object)
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart(System.Object)
=========================================================
Has something been changed internally in the XtraRichEdit control which is causing the above, or is there something wrong with my code?
Many thanks,
Hedley Muscroft
Hi,
I wasn't able to reproduce this behavior. Attached is a project that illustrate my attempts to reproduce your scenario and the issue you are experiencing. Please try to modify this project so that it illustrates the problematic behavior and send it to us.
We will do our best to help you.
OK - please find attached an updated project. It now uses a genuine RTF signature from one of the clients who is experiencing the issue.
In this instance the exception is not thrown when you insert the signature (although we have seen that happen with other clients), however if you try to edit the signature, it crashes and throws a "System.Exception".
For example, try positioning the cursor at the start of the disclaimer line which says "The information contained…" and then start pressing BACKSPACE. This sometimes terminates the program completely and other times throws a "System.Exception".
I hope this helps you to identify the problem so that it can be fixed ASAP… we do have a number of clients reporting this and similar issues with the XtraRichEdit since the last update.
Hi,
We have successfully reproduced the behavior you described and passed this ticket to our developers for further research.
Please bear with us. We will notify you as soon as we make any progress.