使用Visual Studio 2012创建一个可移植类库项目,我想使用XmlDocument类(文档链接)。但是即使使用了,也无法找到该库。
错误信息如下:
如果我右键单击引用 ->“添加引用”,浏览到dll目录(下面的地址),并选择以下dll:
然后点击确定,会出现一个错误。
using System.Xml;
错误信息如下:
"are you missing a using directive or an assembly reference"
如果我右键单击引用 ->“添加引用”,浏览到dll目录(下面的地址),并选择以下dll:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.XML.dll
然后点击确定,会出现一个错误。
"A reference to 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.XML.dll' could not be added.
This component is already automatically referenced by the build system."
因此,一个解决办法是使用开源XML解析库。有什么建议吗?Xerces?
但最好使用内置的C#XmlDocument类。
XmlDocument
,所以**无法在此处使用XmlDocument
**。不过,您可以使用XDocument
- 请参见此处:http://i.stack.imgur.com/bN5N3.png(来自[MSDN](http://msdn.microsoft.com/en-us/library/system.xml.linq.xdocument.aspx))。 - Marc Gravell