C# 无法从Azure移动服务将toast推送到WP8

C# 无法从Azure移动服务将toast推送到WP8,c#,azure,azure-mobile-services,windows-phone-8,C#,Azure,Azure Mobile Services,Windows Phone 8,我在按照教程显示Toast通知时遇到了一些问题 下面是Azure移动服务服务器脚本: function insert(item, user, request) { request.execute({ success: function () { // Write to the response and then send the notification in the background request.respond(); push.m

我在按照教程显示Toast通知时遇到了一些问题

下面是Azure移动服务服务器脚本:

function insert(item, user, request) {
request.execute({
    success: function () {
        // Write to the response and then send the notification in the background
        request.respond();
        push.mpns.sendToast(item.channel, {
           text1:"Sent from cloud!"
       }, {
            success: function (pushResponse) {
                console.log("Sent push:", pushResponse);
            }
        });
    }
});
这是我在App.xaml.cs中输入的代码:

//push notification
    public static HttpNotificationChannel CurrentChannel { get; private set; }


    private void AcquirePushChannel()
    {
        CurrentChannel = HttpNotificationChannel.Find("MyPushChannel");


        if (CurrentChannel == null)
        {
            CurrentChannel = new HttpNotificationChannel("MyPushChannel");
            CurrentChannel.Open();
            //CurrentChannel.BindToShellTile();
            CurrentChannel.BindToShellToast();
        }
    }

private void Application_Launching(object sender, LaunchingEventArgs e)
    {
        AcquirePushChannel();
    }
但是祝酒词仍然没有出来(fliptile工作得很好)

要使烤面包机正常工作,需要做些什么修改吗

编辑: 打开频道时出错:

System.InvalidOperationException was unhandled by user code
  HResult=-2146233079
  Message=Open failed because the channel was already open.  You can find an open channel by calling the Find method.
  Source=Microsoft.Phone
  StackTrace:
       at Microsoft.Phone.Notification.SafeNativeMethods.ThrowExceptionFromHResult(Int32 hr, Exception defaultException, NotificationType type)
       at Microsoft.Phone.Notification.HttpNotificationChannel.Open()
       at UtemFtmkDB.App.AcquirePushChannel()
       at UtemFtmkDB.App.Application_Launching(Object sender, LaunchingEventArgs e)
       at Microsoft.Phone.Shell.PhoneApplicationService.FireLaunching()
       at Microsoft.Phone.TaskModel.Interop.ITask.Launching.Invoke()
       at Microsoft.Phone.TaskModel.Interop.Task.FireOnLaunching()
  InnerException: 

如果收到toast通知时应用程序正在前台运行,则不会在UI中显示toast;相反,您可以通过订阅来接收它。如果这样做,您将在事件处理程序上收到通知

问题中的更新后编辑:要防止调用
打开时出现
无效操作异常
,可以使用以下代码:

专用频道()
{
CurrentChannel=HttpNotificationChannel.Find(“MyPushChannel”);
如果(CurrentChannel==null)
{
CurrentChannel=新的HttpNotificationChannel(“MyPushChannel”);
}
如果(CurrentChannel.ConnectionStatus==ChannelConnectionStatus.Disconnected)
{
CurrentChannel.Open();
}
如果(!CurrentChannel.IsHelltoastBound)
{
CurrentChannel.BindToShellToast();
}
}

CurrentChannel.Open();未知模块中发生“System.InvalidOperationException”类型的异常。但是没有在用户代码中处理这是什么错误,昨天没有这是关于异常的更多信息吗?消息、堆栈跟踪等?