Setting document causes an error

6 posts, 1 answers
  1. Paul
    Paul avatar
    102 posts
    Member since:
    Jun 2010

    Posted 13 Nov 2012 Link to this post

    I am grabbing an RTF document via a web service.  That result is a string (the sRTF variable).  Code to import this into the editor is as follows:

    // Convert to a byte array with the proper encoding
    byte[] byteArray = Encoding.ASCII.GetBytes(sRTF);
    // Then import into the document
    IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(".rtf");
    editor.Document = formatProvider.Import(byteArray);


    Although this works, and I see my document show up correctly, about a half second later the application blows up with the attached error.  I included this as an image to show call stack and other info.  Any ideas anyone?
  2. Paul
    Paul avatar
    102 posts
    Member since:
    Jun 2010

    Posted 13 Nov 2012 Link to this post

    After review, this breaks when simply using the Open button and Telerik's open command.  I found the cause and it's likely a bug.  

    Steps to reproduce:

    1. Set the doucment mode to paged: 
       
    editor.LayoutMode = DocumentLayoutMode.Paged;

    2. Open any file.

    I can fix this by doing the following:
    DocumentLayoutMode? d = editor.LayoutMode;
    editor.LayoutMode = DocumentLayoutMode.Flow;
    editor.Document = formatProvider.Import(byteArray);
    editor.LayoutMode = d;

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Petya
    Admin
    Petya avatar
    975 posts

    Posted 14 Nov 2012 Link to this post

    Hi Paul,

    Thank you for contacting us!

    There are indeed some cases when an ArgumentNullException is thrown in the DocumentPosition class when the document is changed. The problem is in the spell-checker and you can disable spell checking for now (set IsSpellCheckingEnabled = false) until we fix the issue.

    Changing the layout mode of the document before the import will probably not fix the issue in all cases.

    We will try to address this issue in the upcoming service pack. Please, excuse us for the inconvenience.
     
    Regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Paul
    Paul avatar
    102 posts
    Member since:
    Jun 2010

    Posted 14 Nov 2012 Link to this post

    Not a problem.  Thanks for the work around.
  6. Paul
    Paul avatar
    102 posts
    Member since:
    Jun 2010

    Posted 14 Nov 2012 Link to this post

    Just an FYI - The spell checker has nothing to do with it for me.  Disable that and I still get the error.  The only option is to change the page layout to "Flow".  I cannot do this programatically like I thought and change it back to paged layout because the very next time I click anywhere in the document, the error occurs.  For the time being I am disabling page layout mode completely.  I will wait for the service pack.
  7. Petya
    Admin
    Petya avatar
    975 posts

    Posted 16 Nov 2012 Link to this post

    Hi Paul,

    As I said, we have encountered cases in which an exception is thrown in the DocumentPosition class. However, those issues are caused by the spell checker decorations and are resolved when disabling the spell checker.

    This leads to the conclusion that the problem you observe is different, but we have not been able to reproduce it. Moreover, if the issue was caused by the open command that comes out-of-the-box and any document, we would have noticed it as most of our demos use Paged layout mode.

    That said, we would greatly appreciate it if you can open a support ticket  and send us additional details about your setup and a sample document which we can use for testing.

    Thank you in advance!
     
    Greetings,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
UI for WPF is Visual Studio 2017 Ready