2011-12-21 56 views
-6

當在樹視圖中爲許多節點執行下面的代碼時,出現outofmemory異常。在C#中加載xml時出現OutOfMemory異常

XmlTextReader reader = new XmlTextReader(vConditionPaths.InputLogXmlPath); 
_inputItenLogDoc.Load(reader); 
reader.Close(); 

哪裏vConditionPaths.InputLogXmlPath是XML的路徑和_inputItenLogDoc是被聲明爲一類的局部變量的XmlDocument

請幫

+0

修復它?那裏有多少個節點。 32或64位? – TomTom 2011-12-21 09:32:20

+0

'OutOfMemoryException'相當自我解釋。拋出的異常是什麼? – 2011-12-21 09:35:09

回答

1

我假設你的XML文件是大到由XmlTextReader的處理。 (因爲XmlTextReader會嘗試一次讀取整個xml文件)

你可以嘗試一個SAX解析器,它執行順序解析。見http://en.wikipedia.org/wiki/Simple_API_for_XML

對於C#解決方案請參見http://saxdotnet.sourceforge.net/

。據我所知,沒有原生的.net框架薩克斯解析器解決方案。也許任何人都知道一個新的薩克斯解析器.net?我很感興趣:-)