I am rewriting an old .dll into net.core (1.1.1) and one of the methods creates an XmlDocument and defines the namespace via XmlNamespaceManager:
var nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
This throws the following error on build:
The type 'XmlNamespaceManager' exists in both 'System.Xml.ReaderWriter, Version=4.1.0.0, (...) and 'System.Xml, Version=4.0.0.0, ...
According to most posts I've seen, System.Xml.ReaderWriter
is a NuGet, which I do not have installed. I've tried prefixing the XmlNamespaceManager
with System.Xml
but that made no difference.
EDIT:
This is the 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>
EDIT 2:
The Problem seems to be, that System.Xml.ReaderWriter
is added whenever I add a reference to System.Xml
. Setting an alias for System.Xml
does not work and I cannot figure out how to set an alias for System.Xml.ReaderWriter
.