MyBase.Dispose: NullReferenceException was unhandled

M

Martin H.

Hi,

I've got this problem:

I currently work on a control which inherits from ListBox.
In my control I shadowed the Items with a custom ObjectCollection, which
has some additional properties.

Now, this happens:
If I add some entries to my control, click on one of the items and then
close the form with the control on it, I get this error message:

NullReferenceException was unhandled
Object reference not set to an instance of an object

The error occurs in the form's Dispose method at MyBase.Dispose.

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub


I have no clue how to identify the problem, especially since I can
deactivate the click routine and the error still occurs...

Any ideas what the problem could be?

Thanks a lot in advance!

Best regards,

Martin
 
C

Cor Ligthert [MVP]

Matt,

What do you have in the disposing from the by you derived Listbox

Cor
 
M

Martin H.

Hello Cor,
What do you have in the disposing from the by you derived Listbox

I did not write any code for disposing my custom listbox.

Best regards,

Martin
 
B

Brian Gideon

Hi,

I've got this problem:

I currently work on a control which inherits from ListBox.
In my control I shadowed the Items with a custom ObjectCollection, which
has some additional properties.

Now, this happens:
If I add some entries to my control, click on one of the items and then
close the form with the control on it, I get this error message:

NullReferenceException was unhandled
Object reference not set to an instance of an object

The error occurs in the form's Dispose method at MyBase.Dispose.

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

I have no clue how to identify the problem, especially since I can
deactivate the click routine and the error still occurs...

Any ideas what the problem could be?

Thanks a lot in advance!

Best regards,

Martin

Hi,

Can you post a short, but complete program demonstrating the problem?

Brian
 
M

Martin H.

Hi everybody,

I've got the problem solved. It occurred, because I did not add any
items to the base class.

Thanks to all for your help.

Best regards,

Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top