我正在尝试读取用户的公共 Twitter 状态,以便可以在我的 Windows Phone 应用程序中显示它。
我用 Scott Gu 的例子:http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx http://weblogs.asp.net/scottgu/archive/2010/03/18/building-a-windows-phone-7-twitter-application-using-silverlight.aspx
当我的代码从异步调用返回时,只要我尝试使用 e.Result,就会收到“System.Security.SecurityException”。
我知道我的 uri 是正确的,因为我可以将其放入浏览器中并获得良好的结果。
这是我的相关代码:
public void LoadNewsLine()
{
WebClient twitter = new WebClient();
twitter.DownloadStringCompleted += new DownloadStringCompletedEventHandler(twitter_DownloadStringCompleted);
twitter.DownloadStringAsync(new Uri("http://api.twitter.com/1/statuses/user_timeline.xml?screen_name=krashlander"));
}
void twitter_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
XElement xmlTweets = XElement.Parse(e.Result); //exception thrown here!
var message = from tweet in xmlTweets.Descendants("status")
select tweet.Element("text").Value;
//Set message and tell UI to update.
//NewsLine = message.ToString();
//RaisePropertyChanged("NewsLine");
}
有人有什么想法吗?
解决方案:
我终于弄清楚了这一点。我只是忘记取消注释:
WMAppManifest.xml 中的功能。
一旦我这样做了,安全异常就消失了。
我终于弄清楚了这一点。我只是忘记取消注释:
<Capability Name="ID_CAP_NETWORKING"/>
WMAppManifest.xml 中的功能。一旦我这样做了,安全异常就消失了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)