This is NOT a question about the NullReferenceException. It is a question about why the statement shown would be throwing one and what is wrong with it.
I am attempting to parse a small XML document using Linq.Xml and am getting a Null Reference exception when attempting to create a list of objects from a Linq query
_columnDefs = (from def in fileDef.Descendants("columndef")
select new ColumnDef ()
{
Name = def.Attribute("Name").Value,
Type = def.Attribute("Type").Value,
Required = bool.Parse(def.Attribute("Required").Value),
Default = def.Attribute("Default").Value
}).ToList<ColumnDef>();
The code here fails with a NullReferenceException as seen here
I'm having trouble trying to figure out if the new ColumDef object is the issue or something else. If it is the new ColumnDef then why is the "new" operator not creating an instance of the object?
_columnDefs is defined as _columnDefs = new List<ColumnDef>();