I am getting and Unhandled exception when I paste certain text into a Textbox that has the WinSpellChecker hooked up to it. It states "Specified argument was out of the range of valid values. Parameter name: Following(34) offset out of bounds."
To reproduce this in VS 2005 (I am using version 7.3.20073.1041 of the WinSpellChecker)
- Create a new Windows Form
- Drop a Textbox on the form and a WinSpellChecker
- Set the Textbox's property SpellChekerSettings Enabled = True
- Run the application and then PASTE the following text as an example (including the semi-colon)
This will crash&burn Spellchecker;
Right after the text is pasted I receive the error. If I type the same text in the text box it does not cause an error. There are no hidden characters in the string. I typed the text into a new session of Notepad and then copied and pasted it into my test application and it still crashes. If I don't include the semi-colon when I copy the text, it does not crash. Below is the stack trace I am receiving.
Thanks,
Jeff
System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.Parameter name: Following(34) offset out of bounds at Infragistics.Win.UltraWinSpellChecker.FrameWorkSpecific.SimpleTextBoundary.Following(Int32 offset) at Infragistics.Win.UltraWinSpellChecker.FrameWorkSpecific.AdvancedTextBoundary.FollowingProxy(Int32 offset) at Infragistics.Win.UltraWinSpellChecker.FrameWorkSpecific.AdvancedTextBoundary.Following(Int32 offset) at Infragistics.Win.UltraWinSpellChecker.SpellChecker.GetNextWord() at Infragistics.Win.UltraWinSpellChecker.SpellChecker.GetNextWord() at Infragistics.Win.UltraWinSpellChecker.SpellChecker.PreCheck() at Infragistics.Win.UltraWinSpellChecker.SpellChecker.Check(String text, Int32 startPosition) at Infragistics.Win.UltraWinSpellChecker.SpellChecker.Check(String text) at Infragistics.Win.UltraWinSpellChecker.UltraSpellChecker.CheckTextSubString(String text, Int32 startIndex, Int32 length, Object spellCheckTarget) at Infragistics.Win.UltraWinSpellChecker.UltraSpellChecker.CheckNewText(String newText, TextChangeInfo changeInfo, Object spellCheckTarget) at Infragistics.Win.UltraWinSpellChecker.AsYouTypeManager.SpellCheckText(String newText, TextChangeInfo changeInfo, Int32 indexInExcludedWord) at Infragistics.Win.UltraWinSpellChecker.AsYouTypeManager.SpellCheckNewText(Boolean allowErrorAtCursor) at Infragistics.Win.UltraWinSpellChecker.AsYouTypeManager.SpellCheckNewText() at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbacks() at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.TextBoxBase.WndProc(Message& m) at System.Windows.Forms.TextBox.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
This is a bug and I would recommend submitting it to the support group: http://es.infragistics.com/gethelp.
The reason why it only happens when you paste it in and not when you type it in is because the spell checker only spell checks the changes to the text. When you paste the text, it is checking the entire string. When you type it in manually, it is only spell checking the last word you typed in with each character typed.
Mike,
Thanks. I will submit it.
Do you know what in the text is causing the problem? In the real application (not my little test program), my users have the ability to type in freeform comments that get saved off to the database. After the user closed the application, and came back later, the crash was occurring because I was populating the text in the comment text box from the database. I understand how this is the same as the paste in my example because the SpellCheck will run on the entire text.
If I knew what in the text was the problem, I could look for this problem in the saved off data in the database and try to clean it up before others see this problem as well.
Thanks, Jeff
I am currently investigating the issue. It appears the problem is that the spell checker is interpretting the &...; as an XML escaped character and this is cuasing an issue when the ';' is the last thing in the string. It looks like you can work around this issue by setting the spell checker's SpellOptions.AllowXml to False.
Setting the spell checker's SpellOptions.AllowXml to False seems to do the trick. What are the consequences of having this set to False?
Setting AllowXml to True will make the spell checker ignore text withing '<' '>'. If the property is False, text within angle brackets will be spell checked.