【问题标题】:XmlDocument not available in Visual Studio 2012 DLL buildXmlDocument 在 Visual Studio 2012 DLL 版本中不可用
【发布时间】:2013-10-25 08:35:50
【问题描述】:

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

,也找不到该库
using System.Xml;

错误信息是:

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

如果我右键点击References -> “Add References”,浏览到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 解析库。有什么建议么 ?锻炼?

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

【问题讨论】:

    标签: c# xml visual-studio-2012 dll


    【解决方案1】:

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

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

    【讨论】:

    • 感谢回复。我选择了“.Net Framework 4.5”和“.Net for Windows Store Apps”目标框架作品,以保留最广泛的参考。我已经尝试过生成相同错误的其他 System.XML.*.dll 库。
    • @NickT 对;而XmlDocument 在 netcore(又名“.Net for Windows Store Apps”)中不存在,因此您不能在此处使用XmlDocument。但是,您可以使用XDocument - 请参阅此处:i.stack.imgur.com/bN5N3.png(来自MSDN
    • @MarcGravell 有没有办法将一个额外的 API(例如 XmlDocument)(您知道所有目标都支持)连接到 PCL 配置文件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多