Bug Report T300548
Visible to All Users

System.Exception is raised on inserting RTF content located before a newly created bookmark

created 9 years ago

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

Comments (3)
DevExpress Support Team 9 years ago

    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.

    HM HM
    Hedley Muscroft 9 years ago

      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.

      DevExpress Support Team 9 years ago

        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.

        Answers approved by DevExpress Support

        created 9 years ago

        We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

        Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

          Comments (3)
          HM HM
          Hedley Muscroft 9 years ago

            Hi - I notice that you provided the 2014.2.11 hotfix immediately - which is really good - however I need the 2015.1.8 hotfix. Please can you tell me when it will be available?

            HM HM
            Hedley Muscroft 9 years ago

              Actually - I just realised that the "Request hotfix" link doesn't download the fix, it just asks you to provide it, so scratch my last comment, however I do still need the 2015.1.8 hotfix ASAP please!

              DevExpress Support Team 9 years ago

                Hi,

                I can't provide you with a precise date as to when it will be available for downloading. But I can say that if everything goes according to plan, we expect this next week. I hope you will find this information helpful.
                If you need further assistance, let me know.

                Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.