9
votes

On the same code branch we are successfully building on one machine, but on another we get this:

Error Multiple assemblies with equivalent identity have been imported: '...\src\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references.

How can we resolve?

9
All nuget packages? No, I haven't. I was hoping for a faster solution. I have a several projects with this issue. - Daniel
I am able to get the solution to build by deleting references to the above package as well as System.Runtime and System.Runtime.InteropServices that were generating the same error. - Daniel
I can get it to run by removing the dependent assemblies from the config files. <dependentAssembly> <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" /> </dependentAssembly> - Daniel

9 Answers

5
votes

I ultimately solved this by updating Visual Studio to the latest

5
votes

Using MSBuild 15 solves the problem. MSBuild 15 is part of the .NET Core SDK or can be downloaded using the Build Tools for Visual Studio 2017.

1
votes

I suspect that you have both a directly referenced (via the GAC or file system via Browse...) dll and a Nuget package in your project.

Best to try uninstalling the Nuget package, and then check your references and uncheck any remaining references to System.Xml.ReaderWriter.dll, and then install your Nuget reference again.

UPDATE

For reference, a similar error was encountered with System.Threading when an EntityFramework package was renamed. Perhaps one of your packages has a newer version or has a renamed namespace? Or maybe you have incompatible versions of .NET Standard?

1
votes

Solved the "Error Multiple assemblies" problem by uninstalling Xamarin from computer and Visual Studio 15.

Followed this instruction: https://developer.xamarin.com/guides/cross-platform/getting_started/visual_studio_with_xamarin/troubleshooting/uninstall-xamarinvs/

My problem occured when updating asp.net nuget packages from version 1.0.0 to 1.1.0.

1
votes

See https://github.com/dotnet/corefx/issues/14050

This explains that in v4.3.0 of the nuget package it requires using VS 2015 Build tools Update 3 or later.

If you can't upgrade, downgrade the package to v4.0.11.

1
votes

Made the following change to .csproj, which did the trick:

<PackageReference Include="System.Reflection.Emit">
   <Version>4.3.0</Version>
   <ExcludeAssets>All</ExcludeAssets>
   <IncludeAssets>none</IncludeAssets>
</PackageReference>
0
votes

In case someone comes looking for another answer. Can happen (6/6/2018) due to a package reinstall ambiguity between matching namespaces of NetStandard and .NET Framework.

Issue took root updating a NetStandard 3rd party package and it required/installed a dependency of System.Net.NetworkInformation (v4.3.0 I believe.) Honestly worked fine before that package so I manually removed the dependency from CSPROJ and package.config that main solution added.

It's not clean but demonstrates a NuGet or MSBuild issue not recognizing they are in fact different assemblies and thus count as a duplicate reference.

0
votes

Delete the dll in 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'. and build your code.

Add it back after build successfully.

0
votes

I was able to resolve the issue by updating the NuGet package Microsoft.Net.Compilers to a newer version. It had been at 1.0.0, which I believe wasn't using the newer version of MSBuild (as pointed out in some of the other answers).