Throw NotImplementedException

13 posts, 0 answers
  1. Jerel
    Jerel avatar
    7 posts
    Member since:
    Feb 2009

    Posted 05 Apr 2011 Link to this post

    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.
  2. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 08 Apr 2011 Link to this post

    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
  3. DevCraft banner
  4. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 12 May 2011 Link to this post

     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

            }


    ????


  5. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 16 May 2011 Link to this post

    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
  6. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 16 May 2011 Link to this post

    yes I also comment that RadSpellChecker.Check throws object reference not set to an instance of an object. Why?
  7. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 18 May 2011 Link to this post

    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
  8. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 19 May 2011 Link to this post

    yes works, spellchecker pops up and show which words are incorrect, but the suggestions box is empty. why?
  9. Andrew
    Admin
    Andrew avatar
    140 posts

    Posted 19 May 2011 Link to this post

    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
  10. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 19 May 2011 Link to this post

    I referenced both Documents
                                Documents.Proofing
                                Documents.Proofing.Dictionaries.En-US

    still not working and My name is JJ
  11. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 20 May 2011 Link to this post

    still no suggestions; some error ; check my attachment...

  12. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 23 May 2011 Link to this post

    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
  13. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 23 May 2011 Link to this post

    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
  14. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 25 May 2011 Link to this post

    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
Back to Top
DevCraft banner