프로젝트 웹 페이지 중 하나에 다음 코드가 있습니다.XMLException을 처리 할 수없는 것 같습니까?
XmlDocument xDoc = new XmlDocument();
xDoc.Load(File.FullName);
//work through each print batch in this queue file
try
{
XmlNodeList nodeList = xDoc.SelectNodes("Reports/PrintBatch");
foreach (XmlNode printBatch in nodeList)//xDoc.SelectNodes("Reports/PrintBatch"))
{
PrintBatch batch = new PrintBatch();
batch.LoadBatch(printBatch, File.Extension);
this.AddBatch(batch);
}
}
catch (XmlException e)
{
//this report had an error loading!
Console.WriteLine(e.Message);
}
기본적으로 XML 배치 파일을 가져 와서 처리 할 준비가 된 객체로로드합니다.
XML 파일 중 하나가 null 문자 (XML에서는 유효하지 않음)를 포함하고있는 것으로 밝혀지기까지 최근까지도 정상적으로 작동했습니다.
이 "dudd"파일을 처리하려고하면 다음과 같은 예외가 발생합니다.
alt text http://blog.ianmellor.co.uk/images/xml_err.jpg
지금까지는 ..하지만 우리가 "계속"또는 "단계적으로" , 나는 그것이 catch 블록으로 흘러 들어가기를 기대합니다. 그러나, 그렇지 않습니다. 우리는 단순히 죽음의 붉은 화면을 얻습니다 :
alt text http://blog.ianmellor.co.uk/images/xml_err2.jpg
내가 뭘 잘못하고 있니?
비슷한 성공으로 SystemException, Exception, System.Xml.XmlPath.XPathException을 잡으려고 시도했습니다. – Sk93
호기심에서 벗어났습니다. catch (XmlException e) {}가 {}을 (를) catch하도록 변경하면 어떻게됩니까? – Razzie
Razzie : 정확히 동일합니다. 빨간 스크린이 죽었어. – Sk93