找不到类型或名称空间名称 'XmlDocument'。您是否缺少程序集参考?
The type or namespace name 'XmlDocument' could not be found. Are you missing an assembly reference?
我正在尝试使用以下方法解析 xml 文档:
XmlDocument doc = new XmlDocument ();
doc.LoadXml (myXMLstring);
我收到错误:
The type or namespace name 'XmlDocument' could not be
found. Are you missing an assembly reference?
..即使我有
使用 System.Xml;
我不确定什么是程序集引用。我正在使用 Xamarin Studio。我看到有几个文件夹可供参考。在基础项目的引用文件夹中,我没有看到 System.Xml
的条目
但在个别平台中我确实看到了 System.Xml。
我该怎么做才能清除此错误行?
检查您的项目中是否引用了 System.Xml。不幸的是,我不知道如何在 Xamarin Studio 中执行此操作。在 Visual Studio 中,如果展开项目,您将看到 References 目录。如果 System.Xml 不存在,您可以通过右键单击 References 并选择 Add Reference 轻松添加它。之后,您将能够使用 XmlDocument class 和 System.Xml 程序集的全部内容。
您可以使用以下步骤:
- Under the solution explorer on the left, right click on References and select Edit References
- Go to .Net Assembly or All Tab and pick the System.Xml
- Click OK.
正如我在 Xamarin 论坛上发布的那样:http://forums.xamarin.com/discussion/46042/missing-assembly-reference-for-system-xml#latest
使用 XDocument.Parse(string)
从您的便携式 Class 图书馆完成此操作。
XDocument 包含在 System.Xml.Linq
命名空间中,因此您需要在 class.
中为该命名空间添加 using 指令
您无法从便携式 Class 库 (PCL) 访问 XmlDocument
的原因是 PCL 只会公开以下 API在 PCL 目标的所有平台上均受支持。 Windows Phone 8 不支持 XmlDocument,因此在 PCL 中不可用。 Windows 商店应用支持 XmlDocument,但它在不同的命名空间中可用 (Windows.Data.Xml.Dom
)。因此,由于这个原因,System.Xml.XmlDocument
不能从 PCL 使用。通过 PCL 中的 System.Xml
命名空间提供的任何其他内容都可以使用。
只需添加到来源
using Windows.Data.Xml.Dom;
我正在尝试使用以下方法解析 xml 文档:
XmlDocument doc = new XmlDocument ();
doc.LoadXml (myXMLstring);
我收到错误:
The type or namespace name 'XmlDocument' could not be found. Are you missing an assembly reference?
..即使我有 使用 System.Xml;
我不确定什么是程序集引用。我正在使用 Xamarin Studio。我看到有几个文件夹可供参考。在基础项目的引用文件夹中,我没有看到 System.Xml
的条目但在个别平台中我确实看到了 System.Xml。
我该怎么做才能清除此错误行?
检查您的项目中是否引用了 System.Xml。不幸的是,我不知道如何在 Xamarin Studio 中执行此操作。在 Visual Studio 中,如果展开项目,您将看到 References 目录。如果 System.Xml 不存在,您可以通过右键单击 References 并选择 Add Reference 轻松添加它。之后,您将能够使用 XmlDocument class 和 System.Xml 程序集的全部内容。
您可以使用以下步骤:
- Under the solution explorer on the left, right click on References and select Edit References
- Go to .Net Assembly or All Tab and pick the System.Xml
- Click OK.
正如我在 Xamarin 论坛上发布的那样:http://forums.xamarin.com/discussion/46042/missing-assembly-reference-for-system-xml#latest
使用 XDocument.Parse(string)
从您的便携式 Class 图书馆完成此操作。
XDocument 包含在 System.Xml.Linq
命名空间中,因此您需要在 class.
您无法从便携式 Class 库 (PCL) 访问 XmlDocument
的原因是 PCL 只会公开以下 API在 PCL 目标的所有平台上均受支持。 Windows Phone 8 不支持 XmlDocument,因此在 PCL 中不可用。 Windows 商店应用支持 XmlDocument,但它在不同的命名空间中可用 (Windows.Data.Xml.Dom
)。因此,由于这个原因,System.Xml.XmlDocument
不能从 PCL 使用。通过 PCL 中的 System.Xml
命名空间提供的任何其他内容都可以使用。
只需添加到来源
using Windows.Data.Xml.Dom;