C#学习教程:如何使用.Net阅读公共推特提要(在WindowsPhone上)我正在使用ScottGu的示例:http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx当我的When代码从异步调用返回,我一尝试使用e.Result就收到“System.Security.SecurityException”。我知道我的uri是正确的,因为我可以在浏览器中填充它并获得良好的结果。这是我的相关代码:publicvoidLoadNewsLine(){WebClienttwitter=newWebClient();twitter.DownloadStringCompleted+=newDownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);twitter.DownloadStringAsync(newUri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=krashlander"));}voidtwitter_DownloadStringCompleted(objectsender,DownloadStringCompletedEventArgse){XElementxmlTweets=XElement.Parse(e.Result);//这里抛出异常!varmessage=fromtweetinxmlTweets.Descendants("status")selecttweet.Element("text").Value;//设置消息并告诉UI更新。//新闻行=message.ToString();//RaisePropertyChanged("NewsLine");任何人的想法?解决方案:我终于想通了这个。我只是忘记取消注释WMAppManifest.xml中的:function。一旦我这样做了,安全例外就消失了。我终于想到了这个。我只是忘了取消注释:WMAppManifest.xml中的函数。一旦我这样做了,安全例外就消失了。你应该看看TweetSharp。这个对我有用。http://tweetsharp.codeplex.com我在自己的应用程序中遇到了类似的问题。这是我的解决方案:WebClienttwitter=newWebClient();twitter.OpenReadCompleted+=newOpenReadCompletedEventHandler(twitter_OpenReadCompleted);twitter.OpenReadAsync(newUri("http://api.twitter.com..."));和voidtwitter_OpenReadCompleted(objectsender,OpenReadCompletedEventArgse){...}我试过你发布的代码,它没有抛出任何异常,得到了预期的结果,一切似乎都很好。因此,您的PC、网络连接(代理等)上一定有什么东西导致了这种情况。什么是详细异常,StackTrace?也许只是在WindowsPhone7上使用WebClient抛出一个NetworkError会对你有所帮助?当以任何方式交叉引用线程时,通常会发生此异常。在这种情况下,它可能与始终在UI线程上返回的Web客户端有关。您可以使用HttpWebRequest解决问题(无论如何性能更好)。在msdn论坛上查看此线程以获取更多信息您可能想在此处查看可用的应用程序。此应用程序向您显示指定用户名的推文,还允许您将推文导出为pdf、excel、word、图像等。http://blogs.gcpowertools.co.in/2012/05/activereporting-with-twitter.html以上就是C#学习教程:Howtouse.NettoreadthewholecontentsharedbypublicTwitterfeed(onWindowsPhone),如果大家对C#学习教程很有用,需要了解更多。希望大家多多关注。本文收集自网络,不代表立场。如涉及侵权,请点击右侧联系管理员删除。如需转载请注明出处:
