向正在运行的 WP7 应用程序发送 Toast 通知的 Xml 问题
各位, 我已经运行了 WP7 的示例应用程序。我还有一个服务(WCF)和一个推送通知发送器(WPF)。到目前为止,这看起来与微软在 WP7 培训套件中设置的推送通知安排非常相似。当我启动应用程序然后退出应用程序返回主屏幕时,我能够成功发送 Toast 通知 - 它出现在顶部,发出一点噪音,显示正确的文本,并在您时启动我的应用程序点击它。
但是,当我在应用程序在前台运行时向应用程序发送相同的 shell toast 通知时,我收到一条错误消息,指出根 XML 节点存在无效字符。此错误发生在 WP7 的内部深处,因为我的 toast 通知处理程序从未被调用,并且调试器无法向我显示生成错误的代码行。
我正在使用培训套件中的 WP7 推送通知示例附带的NotificationSenderUtility 来发送通知。
如果有人知道为什么会发生这种情况或者我如何解决它,我很想知道,因为我在周六的代码训练营上有一个演示,推送通知应该是演示的一部分:)
这是我得到的堆栈跟踪:
在 System.Xml.XmlTextReaderImpl.Throw(Exception e) 在 System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString, String[] args) 在 System.Xml.XmlTextReaderImpl.Throw(Int32 res, String resString) 在 System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace() 在 System.Xml.XmlTextReaderImpl.ParseDocumentContent() 在 System.Xml.XmlTextReaderImpl.Read() 在 Microsoft.Phone.Notification.ShellObjectChannelInternals.ParseXMLToProperties(String xmlString, IDictionary`2& propertyBag) 在 Microsoft.Phone.Notification.ShellObjectChannelInternals.OnNotificationReceived(IntPtr blob,UInt32 blobSize) 在 Microsoft.Phone.Notification.ShellObjectChannelInternals.ChannelHandler(UInt32 eventType、IntPtr blob1、UInt32 blobSize1、IntPtr blob2、UInt32 blobSize2) 在 Microsoft.Phone.Notification.HttpNotificationChannel.Dispatch(对象 threadContext) 在 System.Threading.ThreadPool.WorkItem.doWork(Object o) 在 System.Threading.Timer.ring()
谢谢, 凯文
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查客户端和发送者上的代码是否符合最新文档。测试期间规范发生了变化。
如何:从 Web 服务发送推送通知对于 Windows Phone
如何:设置为 Windows Phone 建立通知通道
您使用的培训工具包中的工具/代码可能尚未达到规范。
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.