关于.NET库中XmlDocument的Load方法异常无法捕获的情况
private bool LoadXml(string strFilePath){ try { XmlDocument _doc = new XmlDocument(); _doc.Load(strFilePath); XmlNode node = _doc.SelectSingleNode("AISolution"); if (node != null) { return AIFileType.AI_FILE_TYPE_SOLUTION; } } catch (Exception ex) { MessageBox.Show("error"); return false; }}
namespace ConsoleApplication1{ class Program { static void Main(string[] args) { try { XmlDocument _doc = new XmlDocument(); _doc.Load("C:/test.txt"); XmlNode node = _doc.SelectSingleNode("AISolution"); } catch (Exception ex) { Console.WriteLine("Error"); } } }}