我正在编写一个 Windows Phone 8 应用程序。我看到以下错误: System.Windows.ni.dll 中出现“System.OutOfMemoryException”类型的第一次机会异常 我已经划分了导致此错误的代码,但我无法修复它。请随时帮助我
public void getTheWholeChapter(string startbooknum, string startchapter)
{
System.Uri uri = new Uri("http://api.seek-first.com/v1/BibleSearch.php?type=lookup&appid=seekfirst&startbooknum=" + startbooknum + "&startchapter=" + startchapter + "&startverse=1&endbooknum=" + startbooknum + "&endchapter=" + startchapter + "&endverse=5000000&version=KJV");
WebClient client = new WebClient();
OpenReadCompletedEventHandler orceh = new OpenReadCompletedEventHandler(GetTheData);
client.OpenReadCompleted += orceh;
client.OpenReadAsync(uri);
}
private void GetTheData(object sender, OpenReadCompletedEventArgs e)
{
if (e.Error == null)
{
StreamReader reader = new StreamReader(e.Result);
string stringXML = reader.ReadToEnd().ToString();
ListBox tb = new ListBox();
//tb.IsGroupingEnabled = true;
//tb.HideEmptyGroups = true;
//tb.LayoutMode = LongListSelectorLayoutMode.List;
tb.FontSize = 25;
List<TextBlock> listOfVerses = new List<TextBlock>();
//get the deatails from the
if (stringXML != "" && stringXML != null)
{
XDocument root = XDocument.Parse("<Document>" + stringXML.Replace("></a>", "/></a>") + "</Document>");
var ResultsX = from Results in root.Descendants("Result")
select Results;
foreach (var Result in ResultsX)
{
listOfVerses.Add(new TextBlock()
{
Text = Result.Element("Chapter").Value + ":" + Result.Element("Verse").Value + " " + Result.Element("Text").Value,
TextWrapping = TextWrapping.Wrap,
});
}
}
tb.ItemsSource = listOfVerses;
((PivotItem)this.chaptersPivot.Items[chaptersPivot.SelectedIndex]).Content = tb;
}
else
{
//handle this
}
//throw new NotImplementedException();
}