I have a wpf application. when I run it it close. I debugged it and I found that this linq query close it(I don't know why!)
TodayCards = cards.Where(i => (i.NextTime.Day == DateTime.Now.Day && i.NextTime.Month == DateTime.Now.Month && i.NextTime.Year == DateTime.Now.Year)).Select(i => i).ToList();
I also tried
TodayCards = cards.Where(i => (i.NextTime.Day == DateTime.Now.Day && i.NextTime.Month == DateTime.Now.Month && i.NextTime.Year == DateTime.Now.Year)).ToList();
but it closed it both situations.
Most likely
NextTime
isnull
on at least one card orcards
itself isnull
.I found out why!
cards
was null and it close my application. I put this code before my linq query:to find if there is any null next time but it closes before run and I found out the problem is
card
. I can't still say why it close the app without any exceptions but the problem resolved!