Windows phone 8 System.Windows.ni.dll中发生了类型为“System.OutOfMemoryException”的第一次意外异常
我正在编写一个WindowsPhone8应用程序。 我看到以下错误: System.Windows.ni.dll中发生了类型为“System.OutOfMemoryException”的第一次意外异常 我已将导致此错误的代码分区,但无法修复它。请随意帮我Windows phone 8 System.Windows.ni.dll中发生了类型为“System.OutOfMemoryException”的第一次意外异常,windows-phone-8,Windows Phone 8,我正在编写一个WindowsPhone8应用程序。 我看到以下错误: System.Windows.ni.dll中发生了类型为“System.OutOfMemoryException”的第一次意外异常 我已将导致此错误的代码分区,但无法修复它。请随意帮我 public void getTheWholeChapter(string startbooknum, string startchapter) { System.Uri uri = new Uri("http://ap
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();
}
从web api返回的数据大小是多少?api返回圣经的一章。我不确定大小是否是罪魁祸首。当我从第1章滑动到第25章时,它起作用,异常在第26章之后抛出。所以我猜垃圾收集不会在这些方法上发生垃圾收集不会做任何事情,因为你正在把整个事情读到内存中。应用程序有很多优点。