Jef*_*ber 8 .net c# twitter windows-phone-7
我正在尝试阅读用户的公共推特状态,以便我可以在我的Windows Phone应用程序中显示它.
我正在使用Scott Gu的例子: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");
}
Run Code Online (Sandbox Code Playgroud)
任何人的想法?
解决方案:我终于想出了这个.我只是忘了取消注释WMAppManifest.xml中的:功能.一旦我这样做,安全例外就消失了.
我终于弄清楚了这一点。我只是忘记取消注释:
<Capability Name="ID_CAP_NETWORKING"/>
Run Code Online (Sandbox Code Playgroud)
WMAppManifest.xml 中的功能。一旦我这样做了,安全异常就消失了。
归档时间: |
|
查看次数: |
9453 次 |
最近记录: |