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

Throw NotImplementedException

12 Answers 132 Views
SpellChecker
This is a migrated thread and some comments may be shown as answers.
Jerel
Top achievements
Rank 2
Jerel asked on 05 Apr 2011, 04:46 PM
When trying to use the RadSpellChecker class on a standard TextBox a NotImplementedException is thrown, despite the demo showing that this is a perfectly valid scenario. We are using the latest internal build 2011.1.328.1040.

Actually all of the controls throw NotImplemented, it looks like it is an issue with MEF not loading the ControlTypesToSpellChecker. I can manually load the SpellCheckers threw the manager however. This might be a result of the fact that this is an external module, however MEF should still be able to discover the dlls.

12 Answers, 1 is accepted

Sort by
0
Andrew
Telerik team
answered on 08 Apr 2011, 05:31 PM
Hi Jerel,

We tried several scenarios to reproduce the issue you are mentioning. The only problem we found was when  "Reduce XAP size by using application library caching" Silverlight project option is enabled. The problem here consists in that the assemblies are loaded when demanded, so MEF is not able to find them initially. As a work around (which you could have found yourself) we can recommend the following:

ControlSpellCheckersManager.RegisterControlSpellChecker(new TextBoxSpellChecker());
IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox));
ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
documentSpellChecker.AddDictionary(new RadEn_USDictionary(), new System.Globalization.CultureInfo("en-US"));

As MEF couldn't load the ControlSpellCheckers the dictionary you mentioned remains empty, so you can fill it with the
ConWetrolSpellCheckersManager.RegisterControlSpellChecker
method, providing an instance of a class derived from IControlSpellChecker as argument(such IControlSpellCheckers exist for TextBox, RadRichTextBox and RichTextBox in the Telerik.Windows.Control.Proofing namespace).

We realize that this solution is far from perfect and we will do our best to find a better one. However for the time being we recommend this approach.
Don't hesitate to contact us again.

Best wishes,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JJ Loubser
Top achievements
Rank 1
answered on 12 May 2011, 03:13 PM

 private void buttoncheckspelling_click(object sender, RoutedEventArgs e)
        {

            ControlSpellCheckersManager.RegisterControlSpellChecker(new TextBoxSpellChecker());
            IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(TextBox));
            ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
            DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
            documentSpellChecker.AddDictionary(new RadEn_USDictionary(), new System.Globalization.CultureInfo("en-US"));

            //RadSpellChecker.Check(this.KeyWordTextbox, SpellCheckingMode.AllAtOnce); //object reference not set to an instance...

            documentSpellChecker.CheckWordIsCorrect(this.KeyWordTextbox.Text); //does not bring up the SpellChecker box like in the demo

        }


????


0
Andrew
Telerik team
answered on 16 May 2011, 08:12 AM
Hello Jerel,

The code you wrote, is necessary only when the Project Properties option "Reduce XAP size by using application library caching" is enabled. Then Silverlight downloads assemblies on demand so MEF can't load the ControlSpellCheckers and that's why we need to do that manually. 
Now to your question, the method you use DocumentSpellChecker.CheckWordIsCorrect(string text) returns boolean value indicating whether the word provided as argument is in the current dictionary. If you want to show the spellchecking window like in the demo, use RadSpellChecker.Check method.(which you have commented in your ticket)

If you have other questions contact us again.

Regards,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JJ Loubser
Top achievements
Rank 1
answered on 16 May 2011, 08:48 AM
yes I also comment that RadSpellChecker.Check throws object reference not set to an instance of an object. Why?
0
Andrew
Telerik team
answered on 18 May 2011, 08:58 AM
Hello Jerel,

Well, that happens because the SpellCheckAllAtOnce dialog uses RadRichTextBox to present the whole content of the control being spellchecked. So in order to make it work, first you need to register the ControlSpellChecker for the RadRichTextBox and then add a dictionary to it. 
The following code presents what i mean:

ControlSpellCheckersManager.RegisterControlSpellChecker(new TextBoxSpellChecker());
 
ControlSpellCheckersManager.RegisterControlSpellChecker(new RadRichTextBoxSpellChecker());
IControlSpellChecker controlSpellchecker = ControlSpellCheckersManager.GetControlSpellChecker(typeof(RadRichTextBox));
 ISpellChecker spellChecker = controlSpellchecker.SpellChecker;
DocumentSpellChecker documentSpellChecker = (DocumentSpellChecker)spellChecker;
documentSpellChecker.AddDictionary(new RadEn_USDictionary(), new System.Globalization.CultureInfo("en-US"));
 
RadSpellChecker.Check(this.textBox1, SpellCheckingMode.AllAtOnce);

You simply put this code snippet in your button_Click EventHandler and everything should be fine.

Thank you for pointing this out. We realize that throwing null reference exception is not the best behavior in this case and will change it with more informative message.


Kind regards,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JJ Loubser
Top achievements
Rank 1
answered on 19 May 2011, 10:11 AM
yes works, spellchecker pops up and show which words are incorrect, but the suggestions box is empty. why?
0
Andrew
Telerik team
answered on 19 May 2011, 12:21 PM
Hello Jerel,

Most of the times this happens when there is no dictionary loaded. Probably you forgot to add a reference to "Telerik.Windows.Documents.Proofing.Dictionaries.En-US" assembly where our default dictionary resides.

Kind regards,
Andrew
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JJ Loubser
Top achievements
Rank 1
answered on 19 May 2011, 03:43 PM
I referenced both Documents
                            Documents.Proofing
                            Documents.Proofing.Dictionaries.En-US

still not working and My name is JJ
0
JJ Loubser
Top achievements
Rank 1
answered on 20 May 2011, 08:38 AM
still no suggestions; some error ; check my attachment...

0
Iva Toteva
Telerik team
answered on 23 May 2011, 01:45 PM
Hi JJ,

The only reason why no suggestions are shown in the context menu can be that there are no words "similar enough" in the dictionary. The spell checker uses an algorithm for calculating the distance between words in the dictionary and misspelled words. If that distance is bigger than a fixed value, the word is not considered fit for a suggestion.
This is not the case for "foxxx". We suspect that there might be something with the theme you are using that messes up with the suggestion, so we would appreciate it if you could send us a sample project in a General Feedback ticket, so that we can look into the issue and solve the mystery.

All the best,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JJ Loubser
Top achievements
Rank 1
answered on 23 May 2011, 02:15 PM
its not the theme, check my attachment - notthetheme.png
I think it is the dictionary did not add(debuging after documentSpellChecker.AddDictionary(...)) after adding it in the code - dictionaryempty.png , I tried both en-US and en-ZA, same thing...

Answer:
this is a silver-light project, the problem is that I tried to load the dictionaries in code-behind of the button click, no time to asynchronous load there, but when I shift the code you guys gave me to the App.xaml.cs in Application_Startup it works...

thanks guys
0
Iva Toteva
Telerik team
answered on 25 May 2011, 05:42 PM
Hi JJ,

We are glad to hear that you managed to identify the problem and resolve it.

Best wishes,
Iva
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
SpellChecker
Asked by
Jerel
Top achievements
Rank 2
Answers by
Andrew
Telerik team
JJ Loubser
Top achievements
Rank 1
Iva Toteva
Telerik team
Share this question
or