I'm getting an error when sorting a collection. It seems consistent in throwing this error in the code where it lies but it's not repeatable when I try to do it in a seperate piece of code and I can't for the life of me work out why.
The line in question is:
TravelCollection(grdTravelSectors.SelectedItems(0).GetRow.RowIndex).JourneyPaxLink.Sort(JourneyPaxLinkFields.Active.FieldIndex, System.ComponentModel.ListSortDirection.Descending)
The error that is getting thrown is a NullReferenceException - Object reference not set to an instance of an object.
I'm using VB.NET in visual studio 2010 and using LLBLGen Pro 2.6 (I tried upgrading a while ago but have a few tables with dual primary keys that aren't in alphabetical order so decided it was too much work to upgrade when everything was working)
I was targetting .NET 2.0 until recently when I switched to .NET 4.0 - this error didn't start coming up straight away so I don't think it's related to the .NET framework change but you never know.
I've tried running this test code in a different area and this works fine so I just can't see what's going wrong...
Dim TravelCollection As New TravBase.CollectionClasses.ItinerarySectorCollection
TravelCollection.Add(New ItinerarySectorEntity(1536))
TravelCollection.Add(New ItinerarySectorEntity(174))
TravelCollection(0).JourneyPaxLink.Sort(JourneyPaxLinkFields.Active.FieldIndex, _
System.ComponentModel.ListSortDirection.Descending)
TravelCollection(0).JourneyPaxLink.Sort(JourneyPaxLinkFields.LeadPassenger.FieldIndex, _
System.ComponentModel.ListSortDirection.Ascending)
The form where this is happening does an awful lot but it doesn't write anything before it gets to this error.