26

I upgraded to the latest Xamarin for Visual Studio 2015 (Community Edition), recompiled my projects, checked in a few small code changes and my VSTS build server fails with this error message:

[error]CSC(0,0): Error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\mscorlib.dll' and 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll'. Remove one of the duplicate references.

Internet searches return nearly no details about this issue in general and no valuable information at all in the context of VSTS and Xamarin.

The only code change that I consider to be relevant to the issue was done by Visual Studio in the project file:

enter image description here

I only develop for Android, am on Xamarin 4.2 and use the JDK 8 u101.

Any idea how to solve this issue?

Quality Catalyst
  • 5,693
  • 7
  • 34
  • 57

7 Answers7

37

I have just solved the issue. Try removing the mscorlib.dll from the References Folder inside your solution itself. Refer to the below highlighted folder (Reference Folder). It seems that Xamarin will include the mscorlib.dll by default during its build. Hope it helps :)

enter image description here

Emily
  • 513
  • 4
  • 12
DriLLFreAK100
  • 1,266
  • 2
  • 13
  • 23
  • 1
    @biplabrout yes, it does. At least for my case :) – DriLLFreAK100 Sep 26 '16 at 17:03
  • No it didnt worked. After removing I it began showing other error. Resource.designer.cs – biplab rout Sep 26 '16 at 17:12
  • @biplabrout did you removed only the mscorblib.dll file from that folder? or did you removed any other file aside from that one file? – DriLLFreAK100 Sep 26 '16 at 17:17
  • In the vs solution explorer, under the reference dropdown I just removed the mscorlib – biplab rout Sep 26 '16 at 17:21
  • @biplabrout i see.. guess i cant help much here.. sorry bro.. try posting a question on that perhaps? – DriLLFreAK100 Sep 26 '16 at 17:28
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/124234/discussion-between-biplab-rout-and-drillfreak100). – biplab rout Sep 26 '16 at 17:30
  • I also got a subsequent error yet that one seems to be related to a Xamarin/VSTS bug which I'd assume will be fixed later. – Quality Catalyst Sep 27 '16 at 22:50
  • 2
    Worked for me as well – Rolwin Crasta Nov 24 '16 at 11:03
  • @biplabrout what was the problem? – James Esh Feb 21 '17 at 15:27
  • 2
    Thanks, this helped me solve the same error, but with Azure Deployments. Looked at the failed log and removed references, and it fixed the issue. – toddmillernyc Mar 31 '17 at 16:13
  • @toddmillernyc Me too, but also have the old "Found conflicts between different versions of the same dependent assembly that could not be resolved. These reference conflicts are listed in the build log when log verbosity is set to detailed." error. I can't actually find the log where these conflicts are listed though, although I've turned on the Azure website's filesystem logging and set it to verbose. Do you know where it is? – nmit026 Feb 26 '19 at 23:29
  • I updated the NuGet Package Microsoft.NETCore.UWP and deleted 'System' in the References of the UWP Project and it compiled. – Pierre-Louis Deschamps May 13 '19 at 09:11
10

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>
1iveowl
  • 1,342
  • 16
  • 28
4

I had an error installing a .net core nuget, which explicitly installs all the System.* libraries. It turned out that my Microsoft.Net.Compilers package needed upgrading, then this error went away.

David Faivre
  • 2,152
  • 3
  • 22
  • 25
2

I fixed this for myself by changing 7.1 back down to 6.0, and compilation started working again. The problem only appears on my compilation agent:

Compilation settings

TylerH
  • 19,065
  • 49
  • 65
  • 86
Adrián Romero
  • 560
  • 6
  • 17
1

I updated all Microsoft packages and the compiler error went away. So I believe that the general solution for this kind of compiler errors consist in two steps:

  1. Upgrade the involved NuGet package;
  2. If the 1st step is not sufficient, upgrade all Microsoft NuGet packages.
BaSsGaz
  • 950
  • 1
  • 14
  • 27
Ovidiu Caba
  • 31
  • 2
  • 5
1

In my case i had a package reference "Microsoft.NETCore.Portable.Compatibility" in one of the referenced projects. I removed it and Android and iOS projects built successfully.

Adil H. Raza
  • 1,175
  • 13
  • 21
1

I had a similar issue.

the following error was in the jenkins console output

Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\Jenkins\jobs\...\lib\net461\System.ComponentModel.Annotations.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\Facades\System.ComponentModel.Annotations.dll'. 
Remove one of the duplicate references.

I removed the duplicate reference in one of my projects and it worked.

hormberg
  • 154
  • 1
  • 7
  • 3
    I have the same problem, but I'm using a 3:rd party lib that has a dependency on System.ComponentModel.Annotations.dll, so I cannot remove it. – uggeh Oct 31 '18 at 12:15