Windows Phone 7 NotificationChannelOpenException with MS Push Notification HttpNotificationChannel.Open

Issue: Had a NotificationChannelOpenException today when testing out MS Push Notifications  for Windows Phone 7 using code as follows.

            HttpNotificationChannel _channel = new HttpNotificationChannel("NickTest");      �
...
            try
            {             �
                _channel.ChannelUriUpdated += new EventHandler<NotificationChannelUriEventArgs>(channel_ChannelUriUpdated);
                _channel.HttpNotificationReceived += new EventHandler<HttpNotificationEventArgs>(channel_HttpNotificationReceived);
                _channel.ShellEntryPointNotificationReceived += new EventHandler<NotificationEventArgs>(channel_ShellEntryPointNotificationReceived);
                _channel.ShellNotificationReceived += new EventHandler<NotificationEventArgs>(channel_ShellNotificationReceived);
                _channel.ExceptionOccurred += new EventHandler<NotificationChannelExceptionEventArgs>(channel_ExceptionOccurred);

                _channel.Open(); //Error occurs here
                //_channel.BindToShellEntryPoint(); // tile�
                _channel.BindToShellNotification(); // - toast
            }
            catch (NotificationChannelExistsException)
            {
                _channel = HttpNotificationChannel.Find(_channelName);
            }

Exception stack dump was as follows when calling Open on the _channel:

Microsoft.Phone.Notification.NotificationChannelOpenException was unhandled
  Message=NotificationChannelOpenException
  StackTrace:
       at Microsoft.Phone.Notification.SafeNativeMethods.ThrowExceptionFromHResult(Int32 hr, Exception defaultException)
       at Microsoft.Phone.Notification.HttpNotificationChannel.Open()
       at MyStrokes.Provider.NotificationProvider.Subscribe()
       at MyStrokes.App.Application_Startup(Object sender, StartupEventArgs e)
       at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
       at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, String eventName)

Solution:  If you try to Open a channel almost immediately after you hit Debug when emulator fires up this issue will occur.  The solution is simple – Give the emulator two minutes before making the call. 

It appears this is a documented issue in the Windows Phone 7 Developer Tools CTP Release Notes:

  • The push client debugging has to wait for two minutes after boot of the emulator (or device) before using the APIs (i.e. Start screen show up).
  • For push notifications, if the emulator host computer is behind a proxy, SOCKS proxy has to be configured on the host computer.You can go to Control Panel > Network and Internet > Internet Options > Connections tab, and then choose the Setting option to set this configuration. //Also thought this was useful
  •