I have an ObservableCollection, which I even check first to make sure it has elements. And yet I still get a nullReferenceException (only sometimes, this has never had an issue with the winrt 8.1 version, I am changing it to UWP.) The code is below, and it gives me the error where a.Url is:
if (sTumblrblog_gv_list.Count != 0)
{
if (tumblogconfig.ShowNSFWBlogs)
sTumblrGridView.ItemsSource = sTumblrblog_gv_list.OrderBy(a => a.Url);
else
sTumblrGridView.ItemsSource = sTumblrblog_gv_list.OrderBy(a => a.Url).Where(a => a.IsNsfw == false);
}
System.NullReferenceException was unhandled by user code
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Tumblr-FIA
StackTrace:
at tumblr_fia.MainPage.<>c.<updatestats>b__47_1(sTumblrblog_gv a)
at System.Linq.EnumerableSorter`2.ComputeKeys(TElement[] elements, Int32 count)
at System.Linq.EnumerableSorter`1.Sort(TElement[] elements, Int32 count)
at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__1.MoveNext()
at System.Runtime.InteropServices.WindowsRuntime.EnumeratorToIteratorAdapter`1.MoveN
ext()
at System.Runtime.InteropServices.WindowsRuntime.EnumeratorToIteratorAdapter`1.get_HasCurrent()
InnerException:
I understand this error I believe, but I am checking that sTumblrblog_gv_list is not a null value. And I now have it under a try & catch. And still sometimes I receive the error.