Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS 2015 Multiple assemblies with equivalent identity have been imported

One of my project solution is working fine on a system where I have installed VS 2013. But When I open the same project on another system in VS 2015 it is giving this reference error:

Error CS1703 Multiple assemblies with equivalent identity have been imported: 'D:\src\packages\Microsoft.Bcl.1.1.10\lib\net40\System.IO.dll' and 'C:\Program Files (x86)\Reference

Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades\System.IO.dll'. Remove one of the duplicate references.

The project file is referencing the package file, but when it opens in VS it auto converts to Framework library path. I can't uninstall the BCL package because it is a dependency for other packages.

Edit:

Why does the solution build fine in one version of Visual Studio but it gives the multiple assemblies error in another version?

Is there a way to resolve this issue so that it works in different versions?

I also have this issue however his solution builds perfectly in VS 2017 but it cannot build on VS 2015.

like image 785
Pawan Agrawal Avatar asked Mar 20 '17 07:03

Pawan Agrawal


2 Answers

This error usually appears when a NuGet package has invalid dependencies, but this is not the case as everything works well in other versions of Visual Studio.

First you can force reinstall all NuGet packages. That can be done by opening the Package Manager Console and typing:

Update-Package -reinstall

Second most common solution to this problem is to ensure Visual Studio is updated to the latest version (Visual Studio 2015 Update 3 in this case). If that doesn't help, please try reinstalling Visual Studio completely on that device. Finally - you can try to install Visual Studio 2015 on another PC to verify if this is actually a problem of that version, or a PC-specific issue.

like image 184
Martin Zikmund Avatar answered Sep 20 '22 05:09

Martin Zikmund


This error occurs when a non-portable library references to a portable library then the build system adds a facade assemblies. [1]

Try to remove following references:

<Reference Include="System.IO">
  <HintPath>..\packages\System.IO.4.0.10-beta-22516\lib\net45\System.IO.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System.Text.Encoding">
  <HintPath>..\packages\System.Text.Encoding.4.0.10-beta-22516\lib\net45\System.Text.Encoding.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="System.Threading.Tasks">
  <HintPath>..\packages\System.Threading.Tasks.4.0.10-beta-22516\lib\net45\System.Threading.Tasks.dll</HintPath>
  <Private>True</Private>
</Reference>
like image 38
stefan Avatar answered Sep 22 '22 05:09

stefan