Go Back   TX Text Control Community > TX Text Control Discussion and Support Forums > TX Text Control RapidSpell .NET

TX Text Control RapidSpell .NET Please use this forum for TX Text Control RapidSpell .NET support only. If you need support for a different product, please use the appropriate forum.

Reply
 
Thread Tools Display Modes
  #1  
Old December 30, 2009
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Null Reference Error

I keep getting a null reference exception from within the rapid spell dll. Is this a problem in the dll or have I done something wrong? I attached a sample project that has the problem. Simply click “open” to open a document and click “close” to close it, and then repeat. The error occurs when you attempt to open the second document.

Any advice would be appreciated. Thanks!
Attached Files
File Type: zip Spell Check Sample.zip (21.0 KB, 106 views)
Reply With Quote
  #2  
Old January 5, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

Any ideas yet? I have tried changing my approach so I don’t create static spell check objects. Instead, spell check objects are created each time I open a new document. I get the same error. If I don’t dispose the spell check objects the error goes away but then memory usage shoots through the roof as I continue to open/close documents.
Reply With Quote
  #3  
Old January 6, 2010
Reallyethical's Avatar
Reallyethical Reallyethical is offline
TX Text Control MVP
 
Join Date: Sep 2008
Location: Derby, England
Posts: 230
Send a message via Skype™ to Reallyethical
Re: Null Reference Error

Can you paste the relevant code here please, as the attachment is still pending approval.

This sounds like an issue with your creation and freeing of the object.

Regards

Adam
Reply With Quote
  #4  
Old January 6, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

It looks like the attachments are available now. Thanks in advance for your time.
Reply With Quote
  #5  
Old January 11, 2010
Fabian Zenker's Avatar
Fabian Zenker Fabian Zenker is offline
TX Support Engineer
TX Text Control
 
Join Date: Jun 2008
Posts: 72
Re: Null Reference Error

Hi!
Don't use your DisposeWork method by overwriting dispose. You better call that method on using your CloseDoc() method:
Code:
		private void CloseDoc()
		{
			// Don't close if no document open.
			if (panel1.Controls.Count == 0)
			{
				return;
			}

			// Get rid of the document control.
			NGTxTextControl control = (NGTxTextControl)panel1.Controls[0];

                        control.DisposeWork();

			panel1.Controls.Remove(control);
			control.Dispose();

			// Update other controls.
			UpdateControls();
		}
Regards,
Fabian
Reply With Quote
  #6  
Old January 11, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

Thanks Fabian. That seems to solve the problem but I'm not real clear on why.

Can you provide some details?

It looks like all we did was shift things so the text control is detached from spell checking before it is removed from the panel. I liked having it detach in the dispose because it was more automated.

Thanks again!
Mike
Reply With Quote
  #7  
Old January 13, 2010
Reallyethical's Avatar
Reallyethical Reallyethical is offline
TX Text Control MVP
 
Join Date: Sep 2008
Location: Derby, England
Posts: 230
Send a message via Skype™ to Reallyethical
Re: Null Reference Error

Because you have an object reference to a control with no document handled, so closing you are calling a null object and get the error.

The method above will dispose / free the object correctly and you will not get the increase of memory space.

Its just the way the RapidSpell Component has been written. If you were desperate to handle in another fashion you could disassociate all properties before disposing of the object but that seems to be overkill to me.

Sorry I had not posted a reply sooner, I missed the attachments being approved.

Regards

Adam
Reply With Quote
  #8  
Old January 13, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

Thanks for the reply, Adam. I really appreciate it. I don’t mean to belabor the point but this just isn’t making sense to me. You’re saying that when the text control is removed from the panel it no longer has a document? Everything seems to hinge on the “panel1.Controls.Remove(control)” line. If I remove the control from spell checking immediately before that it works fine. If I do it immediately after I get the error. It seems like the spell checking has a problem with the fact that the text control has null for a parent.

Again, I am not trying to be a pain about it. I just want to understand this better because the suggested fix might not be as easy to implement in our real code as it might seem. Can you elaborate on “disassociate all properties”? This might be helpful to me.

Thanks!
Mike
Reply With Quote
  #9  
Old January 13, 2010
Reallyethical's Avatar
Reallyethical Reallyethical is offline
TX Text Control MVP
 
Join Date: Sep 2008
Location: Derby, England
Posts: 230
Send a message via Skype™ to Reallyethical
Re: Null Reference Error

Hi Mike,

I would love to show you but don't have the .net version of TX or RapidSpell available to me at this time so I will have to try and explain in English.

The Spelling Component (RS) is aware of the TX Control (TX) as far as its associated property. if the TX is orphaned while connected to the RS, then the RS will fail on close.

If you set the RS's (its been a while since I have looked at the component) connection properties to disassociate with TX and set the TX RapidSpell Property away from the RS, you will be able to destroy the RS without error.

I hope this makes sense.

Again I would love to code up a C# example for you but just don't have access to the components right now.

P.S. I don't suppose you work for Panda software do you?

Regards

Adam
Reply With Quote
  #10  
Old January 13, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

Thanks again Adam for your quick reply. I'll take the great info that both you and Fabian have provided and see what I can do.

Nope, don't work for Panda.
Reply With Quote
  #11  
Old January 22, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

The solution that involves moving the DisposeWork function call just won't work for me. It results in every user of my control needing to know to do this which is simply not acceptable.

I'd like to use Adam's idea - "If you set the RS's connection properties to disassociate with TX and set the TX RapidSpell Property away from the RS, you will be able to destroy the RS without error."

Does anybody know how to do this? I've been trying but with no success.

Thanks,
Mike
Reply With Quote
  #12  
Old January 25, 2010
Reallyethical's Avatar
Reallyethical Reallyethical is offline
TX Text Control MVP
 
Join Date: Sep 2008
Location: Derby, England
Posts: 230
Send a message via Skype™ to Reallyethical
Re: Null Reference Error

can you post a sample app with the error? I will get hold of the trial and have a play.

Regards

Adam
Reply With Quote
  #13  
Old January 25, 2010
mlmanfredi mlmanfredi is offline
Registered User
 
Join Date: May 2009
Posts: 60
Re: Null Reference Error

Sample is attached to my original post in this thread.

Thanks!
Mike
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object reference not set to an instance of an object techbuilder Support Forum 5 September 18, 2009 09:06:57
Style properties - Bug? Unregistered TX Text Control ActiveX 11 November 7, 2006 13:05:42
user resizes column in second table, object reference not set error David Burson TX Text Control .NET 3 August 15, 2006 13:30:57
Unexpected Text Control error. (1-e00) bsardinha TX Text Control ActiveX 7 August 18, 2004 16:17:34


All times are GMT +1. The time now is 06:01:16.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
© 1991 - 2010 The Imaging Source Europe GmbH