Several of my overriden Equals methods have started throwing Invalid Cast Exceptions -
Unable to cast object of type 'System.DBNull' to type Common.ResolveUser'.
This occurs when binding List (of T) (where T is of type ResolveUser in this case) to a combo.
Equals Method:
Public Overrides Function Equals(ByVal obj As Object) As Boolean
Dim i As ResolveUser = CType(obj, ResolveUser)
If i.UniqueResolveID = UniqueResolveID Then Return True
End Function
Combo-box Binding:
Me.cboPreventativeActionOwner.DataSource = CurrentUser.LoadAllTechniciansAndGreater
Me.cboPreventativeActionOwner.ValueMember = "ID"
Me.cboPreventativeActionOwner.DisplayMember = "FullName"
The ValueMember and FullName properties are populated properly for each item in the collection.
This all used to work fine (and has for about 6 months!)