This is a migrated thread and some comments may be shown as answers.

Setting document causes an error

5 Answers 49 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 13 Nov 2012, 03:40 PM
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?

5 Answers, 1 is accepted

Sort by
0
Paul
Top achievements
Rank 1
answered on 13 Nov 2012, 04:41 PM
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;

0
Accepted
Petya
Telerik team
answered on 14 Nov 2012, 06:12 PM
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.

0
Paul
Top achievements
Rank 1
answered on 14 Nov 2012, 06:13 PM
Not a problem.  Thanks for the work around.
0
Paul
Top achievements
Rank 1
answered on 14 Nov 2012, 09:26 PM
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.
0
Petya
Telerik team
answered on 16 Nov 2012, 01:14 PM
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.

Tags
RichTextBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Paul
Top achievements
Rank 1
Petya
Telerik team
Share this question
or