0

我正在努力处理一些应该很简单但导致意外异常的 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 在这里涉及!感谢您的帮助,马丁

4

1 回答 1

1

只是添加这个,希望它可以帮助遇到同样问题的其他人。事实证明,这是 Monodroid 1.0.8980 中的一个错误,在 Monodroid 1.0.9186 时已修复。升级到新版本解决了我的问题。

于 2011-01-23T17:24:56.087 回答