Title Back Colour Keyoti Title Line Title Curve
Blue Box Top

Null reference exception in GetSuggestionToolStrip - Thesaurus Desktop .NET - Forum

Welcome Guest Search | Active Topics | Log In | Register

Options
whmbraun
#1 Posted : Monday, February 1, 2010 4:32:52 PM
Rank: Member

Groups: Registered

Joined: 2/1/2010
Posts: 27
After I updated to Thesaurus 1.1.1 I get a null reference exception in the following code (used to work previously):

ToolStripItem[] thesaurusSuggestions = null;
// NOTE: This if statement is only a workaround for a bug in Thesaurus.GetSuggestionToolStripItems()!
// If the mouse is right-clicked at the end of the text the method will throw an
// exception (index out of bounds)! GetItem(...) returns null if not at a character
// position. See the code sample "Getting the word at the current mouse position" at
// http://www.textcontrol.c...ds/library/other/chars/
Point mousePos = this.textControl1.PointToClient(Control.MousePosition);
if (this.textControl1.TextChars.GetItem(mousePos, false) != null)
{
thesaurusSuggestions = this.thesaurus1.GetSuggestionToolStripItems();
}

Please note that my comment in the code refers to Thesaurus 1.1.0. I believe there was a bug but the workaround worked just fine. However, after the update I get this exception:

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="Keyoti.Thesaurus.Windows.NET2"
StackTrace:
at Keyoti.Thesaurus.Windows.Thesaurus.GetSuggestionToolStripItems()
at Iwrite4Life.Plugins.Iwrite.IwriteWordProcessor.PopulateSynonyms()
at Iwrite4Life.Plugins.Iwrite.IwriteWordProcessor.contextMenuStrip1_Opening(Object sender, CancelEventArgs e)
at System.Windows.Forms.ToolStripDropDown.OnOpening(CancelEventArgs e)
at System.Windows.Forms.ToolStripDropDown.SetVisibleCore(Boolean visible)
at System.Windows.Forms.ContextMenuStrip.SetVisibleCore(Boolean visible)
at System.Windows.Forms.ToolStripDropDown.Show(Control control, Point position)
at System.Windows.Forms.ContextMenuStrip.ShowInternal(Control source, Point location, Boolean isKeyboardActivated)
at System.Windows.Forms.Control.WmContextMenu(Message& m, Control sourceControl)
at System.Windows.Forms.Control.WmContextMenu(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at TXTextControl.TextControlBase.WndProc(Message& message)
at TXTextControl.TextControl.WndProc(Message& message)
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)
InnerException:


Wolfgang
Wolfgang
Jim
#2 Posted : Monday, February 1, 2010 10:23:52 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
Hi Wolfgang, sorry about the problem. I looked at the code change from 1.1.0 to 1.1.1 and there is nothing related to GetSuggestionToolStripItems. So I'm not sure that 1.1.1 is to blame, perhaps it's related to another change that happened? Did you go to a new TX version?

Would you be able to post (via senduit.com or email to support) a simple example that reproduces it please?

Thanks
Jim


-your feedback is helpful to other users, thank you!
-your feedback is helpful to other users, thank you!


whmbraun
#3 Posted : Tuesday, February 2, 2010 5:31:59 AM
Rank: Member

Groups: Registered

Joined: 2/1/2010
Posts: 27
Hi Jim,

I had posted a second problem (registration dialog keeps popping up) shortly after this post (Dan had responded). It only occurred to me later that maybe the null reference is a consequence of the registration problem. Dan suspected the licenses.licx file(s) - the usual culprits. I had sent them but not yet had an answer.



Wolfgang
Wolfgang
whmbraun
#4 Posted : Friday, February 5, 2010 10:33:46 AM
Rank: Member

Groups: Registered

Joined: 2/1/2010
Posts: 27
Jim, Dan,

I have to apologize for this false alarm. Here is what happened: I had removed and then re-added the thesaurus control from my form in the designer in the hope of solving the licensing problem that I reported in the other thread. What I forgot to do though, was to set the newly added thesaurus control's ThirdPartyTextControl property back to the adapter. Of course the thesaurus control complained during runtime about a null reference!

Sorry again and thanks for your help.

Wolfgang
Wolfgang
Jim
#5 Posted : Friday, February 5, 2010 2:53:05 PM
Rank: Advanced Member

Groups: Administrators, Registered

Joined: 8/13/2004
Posts: 2,669
Location: Canada
No problem Wolfgang, thanks for the update.

Jim


-your feedback is helpful to other users, thank you!
-your feedback is helpful to other users, thank you!


Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.




About | Contact | Site Map | Privacy Policy

Copyright © 2002- Keyoti Inc.