2012-04-19 39 views
0

我在WinRT Metro應用程序上寫了一個小應用程序。我需要讀取XML文件,我得到一個可怕收到COMException:/COMException未被用戶代碼處理(來自HRESULT的異常:0xC00CE508)win8 metro apps

這是應該閱讀XML:

Windows.Storage.StorageFolder storageFolder = await 
    Windows.ApplicationModel.Package.Current.InstalledLocation 
    .GetFolderAsync("Common"); 

Windows.Storage.StorageFile storageFile = await 
    storageFolder.GetFileAsync("testFile.xml"); 

var stream = await storageFile.OpenAsync(Windows.Storage.FileAccessMode.Read); 

XmlDocument doc = await XmlDocument.LoadFromAsync(storageFile); 

有人可以給我薩姆提示,使工作?

+0

相當確定錯誤代碼意味着xml文檔包含無效字符。可能是錯誤的編碼。在VS中打開文件。 – 2012-04-19 17:40:02

回答

0

爲什麼使用OpenAsync()? (更進一步,不命名方法LoadFromAsync存在嗎?) 請參閱此網頁:How to read and write data into XML file In Metro style apps ?

順便說一句,錯誤0xC00CE508在很多情況下出現,而分析XML。請使用XmlDocument.LoadXml(String)方法檢查XML的內容是否有錯誤。

相關問題