I have a bizzare issue that I am struggling to resolve:
I have a form that performs a number of different searches using LINQ queries. 99% of the time the code will execute fine without any errors what so ever, however, on total random occasions, my form falls over on the following line:
'Find all tickets belonging to a user
Dim _userTicketsList As List(Of Ticket) = Tickets.FindAll(Function(p)
p.ticket_firstname.ToUpper = NewSearchString And
CDate(p.ticket_created_at.Value.ToShortDateString) >= date1
And CDate(p.ticket_created_at.Value.ToShortDateString) <= date2)
The error I get is Object Reference Not Set To An Instance Of An Object
From then on, any search will continue to bomb out on this line of code, until I restart my app. I execute the search again and everything works fine.
I cannot understand what is causing this error to occur. It can happen if .FindAll
returns 0 results or if it returns any number of results.
Is there anyway I can determine what Object is trying to get set? I'm assuming its _userTicketsList
but it doesn't make sense why sometimes it works and sometimes it doesn't.
I know it's probably hard to comment without seeing every bit of code, but is there anyway I can try and debug this differently? The debugger sits on this line of code for 23,000+ Ticket
items, so I can't even work out if there is a specific Ticket
that is causing the issue.
Any help or direction is greatly appreciated. Thanks