在我发送 toast 通知之前,我的应用程序上有一个运行良好的后台代理,它引发未处理的异常,异常对象消息为:“对象引用未设置为对象的实例。” OnInvoke 方法是异步的,因为我执行的异步请求非常有效。抛出异常的代码如下
ShellToast toast = new ShellToast();
toast.Title = "hello";
toast.Show();
我不知道问题可能出在哪里,在此先感谢您的帮助。
编辑: 这是堆栈跟踪:
at Microsoft.Phone.Shell.ShellToast.Show()
at ScheduledTaskAgent1.ScheduledAgent.<OnInvoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.AsyncMethodBuilderCore. <ThrowAsync>b__4(Object state)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()