2012-06-27 4 views
-1

, 그것은 오류오류를 해결하는 방법 나는 아래의 코드를 실행하면

을 보여주고있다 "호출 대상이 예외를 Throw했습니다"

"호출 대상이 예외를 Throw했습니다"

이 문제를 해결하려면 어떻게해야합니까?

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 
} 
+5

내부 예외는 무엇입니까 "D:\\Data.xml"? – Zabavsky

답변

0

XDocument document = XDocument.Load(@"D:\Data.xml"); 

모두 동일해야하지 @"D:\Data.xml"

+0

'@ "D \ Data.xml"및 "D : \\ Data.xml"(후자는'@') –

관련 문제