来自 IncrementalLoadingCollection WinRT 应用程序的奇怪异常

Odd exception coming from IncrementalLoadingCollection WinRT app

Bugsense 告诉我,在我的 WinRT Phone 应用程序中,我遇到了很多这样的异常

标题:

通过等待任务或访问其异常未观察到任务的异常 属性。结果,未观察到的异常被终结器线程重新抛出。

和这个堆栈跟踪:

    0 System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. ---> System.NullReferenceException: Object reference not set to an instance of an object.           

 1 at ABC.Core.IncrementalLoadingCollection`1.<>c__DisplayClass20_0.<<LoadMoreItemsAsync>b__0>d.MoveNext()
    2 --- End of inner exception stack trace ---
    3---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
    4 at ABC.Core.IncrementalLoadingCollection`1.<>c__DisplayClass20_0.<<LoadMoreItemsAsync>b__0>d.MoveNext()<---
    5
    6--- Inner exception of type System.NullReferenceException start ---
    7--- Message: Object reference not set to an instance of an object. ---
    8System.NullReferenceException: Object reference not set to an instance of an object.
    9 at ABC.Core.IncrementalLoadingCollection`1.<>c__DisplayClass20_0.<<LoadMoreItemsAsync>b__0>d.MoveNext()
    10--- End of inner exception stack trace ---

有没有人以前有过这个?我应该将 IncrementalLoadingCollection 移动到主应用程序中,而不是将 class 放在单独的 dll 中吗?

在 DLL 中应该无关紧要;您应该打开第一次机会异常,以便找出异常发生的位置并修复它 - 显然 null 不应该出现的情况。您可以通过 Debug -> Exceptions 对话框并检查 Thrown 列来打开第一次机会异常.

此外,作为一般做法,您不应该使用不保护自身不受异常影响(或不明确依赖其调用者这样做)的异步方法。