【发布时间】:2014-04-16 07:38:44
【问题描述】:
我使用以下代码创建推送通知通道。
问题是当我执行代码时,大多数时候(并非总是),这个函数抛出System.NullReferenceException。但是,如果我设置断点并逐步调试它,它可以正常工作并返回有效的HttpNotificationChannel。
private string AcquirePushChannel()
{
HttpNotificationChannel currentChannel = HttpNotificationChannel.Find("MyPushChannel");
if (currentChannel == null)
{
currentChannel = new HttpNotificationChannel("MyPushChannel");
currentChannel.Open();
currentChannel.BindToShellTile();
currentChannel.BindToShellToast();
}
currentChannel.ChannelUriUpdated += (s, e) =>
{
// Code here
};
currentChannel.ShellToastNotificationReceived += async (s, e) =>
{
// Code here
};
return currentChannel.ChannelUri.AbsoluteUri;
}
由于一步一步调试它工作正常,我无法找到问题所在。有什么想法吗?
【问题讨论】:
标签: c# windows-phone-8 push-notification windows-phone mpns