I have a background agent on my app that works well until I send a toast notification, it throws an unhandled exception with the exception object message being: "Object reference not set to an instance of an object." The OnInvoke method is async as I do async request that works perfectly. The piece of code that throws the exception is the following
ShellToast toast = new ShellToast();
toast.Title = "hello";
toast.Show();
I have no clue on where the issue might be, thanks in advance for the help.
Edit: Here is the Stacktrace:
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()