- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在将一个旧的 .dll 重写到 net.core (1.1.1) 中,其中一种方法创建了一个 XmlDocument 并通过 XmlNamespaceManager 定义了命名空间:
var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
这会在构建时抛出以下错误:
The type 'XmlNamespaceManager' exists in both 'System.Xml.ReaderWriter, Version=4.1.0.0, (...) and 'System.Xml, Version=4.0.0.0, ...
根据我看到的大多数帖子,System.Xml.ReaderWriter
是一个 NuGet,我没有安装它。我试过在 XmlNamespaceManager
前加上 System.Xml
前缀,但这没有任何区别。
编辑:
这是csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<OutputType>exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<ApplicationIcon />
<OutputTypeEx>exe</OutputTypeEx>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="System.Xml">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.Xml.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
编辑 2:
问题似乎是,每当我添加对 System.Xml
的引用时,都会添加 System.Xml.ReaderWriter
。为 System.Xml
设置别名不起作用,我不知道如何为 System.Xml.ReaderWriter
设置别名。
最佳答案
问题是因为该类存在于两个 dll [Same (Namespace + TypeName)] 中,并且它无法解析您要使用哪个。
你应该 extern Alias the dll 即 alias the Dlls。在 Visual Studio 中,您可以查看 dll 属性,然后在别名列中提供别名。然后在代码中使用
引用该 dll外部别名dllaliasname;
这应该可以消除构建错误。
看看这个链接。
https://blogs.msdn.microsoft.com/ansonh/2006/09/27/extern-alias-walkthrough/
也看看这个。
关于C# - XmlNamespaceManager 存在于 'System.Xml.ReaderWriter' (...) 和 'System.Xml (...)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43622709/
对于为什么(至少在 .Net Framework 中),我已经有点干巴巴地想出了为什么有必要使用 XmlNamespaceManager 。为了在执行 XPath 查询时处理 namespace (或
我不想再问 XPath/XmlNamespaceManager 问题,但我似乎无法弄明白。 我使用了 XpathVisualizer 工具,它可以使用 XPath“//FuelGradeMovemen
因此,当我使用 selectSingleNode 获取空值时,我发现我需要声明一个 namespace ,因为我正在使用 xmlns 属性。我的问题是,如果我不在 xml 文件本身中使用前缀,为什么在
我正在尝试使用 XmlNamespaceManager 将 namespace 添加到 XmlDocument。这是当前的 xml: 我希望它转换为这个 xml(
我正在尝试从 XML File 中读取数据.在此元素中,前缀为“app”和“gml”文本。由于这些前缀,我无法读取数据。为此,我试图通过使用 XMLNamespaceManager 但没有获取来添加命
多年来,我一直在寻找一种方法来从具有多个命名空间的 XmlNode(不是 XmlDocument)中选择节点。 几乎我搜索过的每篇帖子都建议我使用 XmlNamespaceManager,但是,Xml
我有一些在 sharepoint 上运行的 C# 代码,我用它来检查 infopath 文档的 xml 内部,看看我是否应该检查文档或丢弃文档。 代码在我创建的几个不同的表单模板上运行良好,但在我最新
我有一些带有默认命名空间的 xml 并想统计 的数量 我该如何定义 XmlNamespaceManager nsmgr = ???? Assert.AreEqual(2, doc.SelectNo
我正在尝试测试如下所示的 XML 文档(在本例中为 SAML):
我正在尝试阅读以下内容并在其中选择一个节点 . XmlDocument document = new XmlDocument(); document.Load(Ser
我正在将一个旧的 .dll 重写到 net.core (1.1.1) 中,其中一种方法创建了一个 XmlDocument 并通过 XmlNamespaceManager 定义了命名空间: var ns
我是一名优秀的程序员,十分优秀!