[MonoTouch] LINQ crash - pulling my hair out

Jason Awbrey jason at awbrey.net
Mon Dec 19 15:12:24 EST 2011


I use LINQ to parse XML a lot in my app, and generally don't have problems.

However, I ran into something this morning that is driving me nuts:

I have some XML that looks like this (this is the fragment within a larger
doc)

<HighRiskMapAreaList xmlns:a="
http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>AAA</a:string>
</HighRiskMapAreaList>

I need to extract a list of strings contained within HighRiskMapAreaList.

I'm doing this:

XNamespace ns = "http://schemas.microsoft.com/2003/10/Serialization/Arrays";

// this works and q.Count() is 1
var q = (from x in DataDoc.Descendants("HighRiskMapAreaList") select
x.Element(ns + "string"));

foreach (XElement e in q)
{
  // this works in LinqPad, but crashes in MT with a null reference
exception
  Console.WriteLine(e.Value);
}

any ideas?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20111219/ff96f6a1/attachment.html 


More information about the MonoTouch mailing list