|
|||||||
| 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. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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! |
|
#2
|
|||
|
|||
|
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.
|
|
#3
|
||||
|
||||
|
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 |
|
#4
|
|||
|
|||
|
Re: Null Reference Error
It looks like the attachments are available now. Thanks in advance for your time.
|
|
#5
|
||||
|
||||
|
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();
}
Fabian |
|
#6
|
|||
|
|||
|
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 |
|
#7
|
||||
|
||||
|
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 |
|
#8
|
|||
|
|||
|
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 |
|
#9
|
||||
|
||||
|
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 |
|
#10
|
|||
|
|||
|
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. |
|
#11
|
|||
|
|||
|
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 |
|
#12
|
||||
|
||||
|
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 |
|
#13
|
|||
|
|||
|
Re: Null Reference Error
Sample is attached to my original post in this thread.
Thanks! Mike |
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
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 |