我正在努力处理一些应该很简单但导致意外异常的 Monodroid 代码。当我尝试在 XmlDocument 对象上调用 SelectNodes() 时,代码会引发异常。
这是代码:
XmlDocument handXmlDocument = new XmlDocument();
XmlDeclaration dec = handXmlDocument.CreateXmlDeclaration("1.0", null, null);
handXmlDocument.AppendChild(dec);
XmlElement root = handXmlDocument.CreateElement("friendslist");
handXmlDocument.AppendChild(根);
XmlElementfriendElement = handXmlDocument.CreateElement("friend");
friendElement.SetAttribute("locationx", "35");
friendElement.SetAttribute("locationy", "46");
friendElement.SetAttribute("电话", "4085556803");
root.AppendChild(friendElement);
XmlNodeListfriendNodeList = handXmlDocument.SelectNodes("/friendslist/friend");
这是一个例外:
E / mono(365):[0x45eec0:]异常处理:System.TypeInitializationException:System.Console的类型初始化程序抛出异常E / FriendsView(365):解析XML文档的异常:类型初始化程序抛出异常对于 System.Console E/FriendsView(365):解析 XML 文档的内部异常:System.ExecutionEngineException:SIGILL E/FriendsView(365):在 /Users/plasma/Work/mono 中的 System.Console..cctor () [0x00019] -android-trunk/mcs/class/corlib/System/Console.cs:127
我不知道为什么 System.Console 在这里涉及!感谢您的帮助,马丁