<分区>
我有一个 ObservableCollection,我什至先检查它以确保它有元素。但是我仍然得到一个 nullReferenceException(只是有时,这在 winrt 8.1 版本中从来没有出现过问题,我正在将其更改为 UWP。) 代码在下面,它给了我 a.Url 所在的错误:
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:
我相信我理解这个错误,但我正在检查 sTumblrblog_gv_list 是否为空值。我现在已经在尝试和捕捉它了。有时我仍然会收到错误消息。