XmlDocument 在 Visual Studio 2012 DLL 版本中不可用



使用Visual Studio 2012,创建一个可移植类库项目,我想使用XmlDocument类。但是,即使有

using System.Xml;

错误消息是:

"are you missing a using directive or an assembly reference"

如果我右键单击引用 ->"添加引用",浏览到 dll 目录(下面的地址),然后选择以下 dll:

C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.XML.dll

然后单击"确定",出现错误

"A reference to 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.XML.dll' could not be added. 
This component is already automatically referenced by the build system."

因此,解决方法是使用开源XML解析库。有什么建议吗?薛塞斯?

但最好使用内置的 C# XmlDocument 类。

实际上,XmlDocument并非在所有框架上都可用,因此在 PCL 中可能不可用(具体取决于您选择的框架选项)。但是,较新的XDocument通常是 - 如有必要,请尝试添加对System.Xml.Linq.dll的引用。

PCL 的全部意义在于,它将您限制为所有选定框架上可用的严格组件子集。