当我运行以下代码时,它显示错误
“调用的目标已抛出异常”
我能做些什么来解决这个问题?
public LinqToXml()
{
XDocument document = XDocument.Load(@"D:\\Data.xml");
#region Fetch All the Books
var books = from r in document.Descendants("book")
select new
{
Author = r.Element("author").Value,
Title = r.Element("title").Value,
Genere = r.Element("genre").Value,
Price = r.Element("price").Value,
PublishDate = r.Element("publish_date").Value,
Description = r.Element("description").Value,
};
foreach (var r in books)
{
com_xdocuments.Items.Add(r.PublishDate + r.Title + r.Author);
}
#endregion
}