且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

找不到类型或命名空间名称“XmlDocument".您是否缺少程序集参考?

更新时间:2023-11-19 22:55:58

正如我在 Xamarin 论坛上发布的:http://forums.xamarin.com/discussion/46042/missing-assembly-reference-for-system-xml#latest

As I posted on the Xamarin forums: http://forums.xamarin.com/discussion/46042/missing-assembly-reference-for-system-xml#latest

使用 XDocument.Parse(string) 从您的可移植类库中完成此操作.

Use XDocument.Parse(string) to accomplish this from your Portable Class Library.

XDocument 包含在 System.Xml.Linq 命名空间中,因此您需要在类中为该命名空间添加 using 指令.

XDocument is included in the System.Xml.Linq namespace so you will need to add the using directive for that namespace in your class.

您无法从可移植类库 (PCL) 访问 XmlDocument 的原因是因为 PCL 将仅公开在 PCL 目标的所有平台上都支持的 API.Windows Phone 8 不支持 XmlDocument,因此这在 PCL 中不可用.Windows 应用商店应用支持 XmlDocument,但它在不同的命名空间 (Windows.Data.Xml.Dom) 中可用.因此,出于这个原因,System.Xml.XmlDocument 不能从 PCL 中使用.通过 PCL 中的 System.Xml 命名空间提供的任何其他内容都可以使用.

The reason that you cannot access XmlDocument from a Portable Class Library (PCL) is due to the fact that a PCL will only expose APIs that are supported on all platforms that the PCL targets. Windows Phone 8 does not support XmlDocument, and so this isn't available in the PCL. Windows Store apps support XmlDocument but it is available in a different namespace (Windows.Data.Xml.Dom). So for this reason System.Xml.XmlDocument cannot be used from the PCL. Anything else provided through the System.Xml namespace in the PCL is fine to use.