MyBase.Dispose: NullReferenceException was unhandled

  • Thread starter Thread starter Martin H.
  • Start date Start date
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
 
Matt,

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

Cor
 
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
 
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
 
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
 
Back
Top