3

Folks, I've got my sample application for WP7 running. I've also got a service (WCF) and I've got a push notification sender (WPF). So far this looks pretty similar to the push notification arrangement that Microsoft has set up in the WP7 training kit. When I launch the app and then exit the app to go back to the home screen, I am able to successfully send a toast notification - it appears on the top, makes a little noise, displays the right text, and launches my app when you tap it.

However, when I send the same exact shell toast notification to my application while the application is running in the foreground, I get an error complaining that there is an invalid character for the root XML node. This error occurs deep within the bowels of WP7 as my toast notification handler is never called and the debugger can't show me the line of code that generated the error.

I am using the NotificationSenderUtility that comes with the WP7 push notification sample in the training kit to send the notifications.

If anybody knows why this is happening or how I can fix it, I would love to know because I've got a demo I'm giving at a code camp on Saturday and push notifications are supposed to be part of the demo :)

Here's the stack trace I get:

at System.Xml.XmlTextReaderImpl.Throw(Exception e) at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString, String[] args) at System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString) at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() at System.Xml.XmlTextReaderImpl.ParseDocumentContent() at System.Xml.XmlTextReaderImpl.Read() at Microsoft.Phone.Notification.ShellObjectChannelInternals.ParseXMLToProperties(String xmlString, IDictionary`2& propertyBag) at Microsoft.Phone.Notification.ShellObjectChannelInternals.OnNotificationReceived(IntPtr blob, UInt32 blobSize) at Microsoft.Phone.Notification.ShellObjectChannelInternals.ChannelHandler(UInt32 eventType, IntPtr blob1, UInt32 blobSize1, IntPtr blob2, UInt32 blobSize2) at Microsoft.Phone.Notification.HttpNotificationChannel.Dispatch(Object threadContext) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring()


Thanks, Kevin

Eran
  • 387,369
  • 54
  • 702
  • 768
Kevin Hoffman
  • 5,154
  • 4
  • 31
  • 33

1 Answers1

2

Check your code on client and sender complies with the latest documentation. There was a change to the spec during beta.

How to: Send a Push Notification from a Web Service for Windows Phone

How to: Set Up a Notification Channel for Windows Phone

It's possible the tools/code you're using from the training kit hasn't been brought up to spec with that yet.

Mick N
  • 14,892
  • 2
  • 35
  • 41
  • The code from the training kit is based on the RTW and so is the documentation from the training kit. I've compared the code the training kit class is using compared with the XML that its expecting and it all matches. Also remember that the toast works when the application is not in the foreground.. It only fails when the application is not running in the foreground. Also, the code I am using in my WP7 application is not from the training kit, it's from the document you link to "How to: Set up a notification channel for windows phone" – Kevin Hoffman Nov 01 '10 at 23:40
  • I meant to imply checking the code that's sending the toast as well to see if the tool you're using for this from the training kit isn't up to date. – Mick N Nov 01 '10 at 23:50
  • 1
    I yanked all the training kit crap out of my application, despite the training kit being certified for the RTW version of the SDK. Amazingly enough, sending the HTTP POST myself and not using the training kit class fixed my problem. Dammit. I HATE it when "demo code" actually causes more problems than it solves. – Kevin Hoffman Nov 01 '10 at 23:59
  • Yea, there's a bit of work with keeping doco and training material up to date with moving sdks. Sometimes it lags a bit as teams play catchup.. had a feeling that would be the culprit in this case. Glad to you're sorted. Good that it's documented here at least now until it's resolved. – Mick N Nov 02 '10 at 00:05