【发布时间】:2013-12-17 18:55:11
【问题描述】:
我想加载一个通过从我的数据库中获取数据而创建的 XML 文件。 但是,如果我想读取该数据,它会显示第 1 行有错误。 第 1 行确实很奇怪,因为我从未要求过“ArrayOfBand”。但即使它在那里,当我设置一个断点时,我也会得到我所有的乐队。它只是在最后一步崩溃。错误 HRESULT:0xC00CE556
本地主机上的 XAML
<ArrayOfBand xmlns:i="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.datacontract.org/2004/07/WindowsStoreApp.Models">
<Band>
<Description>Noorse DJ</Description>
<Facebook>Avicii</Facebook>
<ID>156</ID>
<Name>Avicii</Name>
<Picture>..\Images\Avicii.jpg</Picture>
<Twitter>#Avicii</Twitter>
</Band>
<Band>
<Description>Heavy Metal</Description>
<Facebook>A7X</Facebook>
<ID>157</ID>
<Name>Avenged Sevenfold</Name>
<Picture>..\Images\A7X.jpg</Picture>
<Twitter>#A7X</Twitter>
</Band>
</ArrayOfBand>
C# xml 阅读器
string m_strFilePath = "http://localhost:17281/api/Band";
XmlDocument myXmlDocument = new XmlDocument();
myXmlDocument.Load(m_strFilePath); //Load NOT LoadXml
XmlNodeList elemList = myXmlDocument.GetElementsByTagName("Band");
for (int i = 0; i < elemList.Count; i++)
{
XAML station = new XAML() {
ID = elemList[i].Attributes["ID"].InnerText,
Name = elemList[i].Attributes["Name"].InnerText
};
list.Add(station);
}
return list;
}
c# for creating the xml file
您可以看到我不是要“ArrayOfBand”。如果我获取文件并删除“ArrayOfBand”,它会完美运行。任何人都知道它为什么在那里? 公共静态列表 GetBands() { 列表列表 = 新列表(); DbDataReader reader = Database.GetData("SELECT * FROM Band");
while (reader.Read())
{
Band b = new Band();
b.ID = reader["ID"].ToString();
b.Name = reader["Name"].ToString();
b.Picture = reader["Picture"].ToString();
b.Description = reader["Description"].ToString();
b.Twitter = reader["Twitter"].ToString();
b.Facebook = reader["Facebook"].ToString();
list.Add(b);
}
return list;
}
【问题讨论】:
-
究竟是什么错误?
-
检查内部异常,通常会告诉你真正的问题是什么。
-
内部异常为空
-
错误是 HRESULT: 0xC00CE556