Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple assemblies with equivalent identity error with Xamarin.iOS

I'm attempting to build a Xamarin iOS app using .NET Standard 2.0 dependencies. One of these dependencies includes a reference to the System.Reflection.Emit 4.3.0 NuGet package. This causes a build error when the iOS app is built, as this dll conflicts with the reference facade for System.Reflection.Emit:

CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\Users\ndesl.nuget\packages\system.reflection.emit\4.3.0\ref\netstandard1.1\System.Reflection.Emit.dll' and 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll'. Remove one of the duplicate references.

Anyone knows how to deal with this? Shouldn't those assemblies be recognised as 2 versions of the same assembly?

Attempting to specify a binding redirect in app.config doesn't help. I'm using the latest versions of Xamarin and VS2017.

A minimal project exhibiting the issue can be found here: https://github.com/nicodeslandes/ReflectionEmitBuildIssue

like image 857
ndeslandes Avatar asked Dec 16 '17 22:12

ndeslandes


2 Answers

Convert your iOS project to use PackageReference in the csproj file instead of packages.config. See Issues with .NET Standard 2.0 with .NET Framework & NuGet on dotnet/announcements GitHub and Using Xamarin Forms with .NET Standard – VS 2017 Edition for more information.

like image 66
desmondgc Avatar answered Nov 13 '22 07:11

desmondgc


Note: I was facing same issue on MAC version of visual studio but hopefully this will work fine for you as well.

Solution: After spending few hours I found a workaround here in answer no. 2.

Simply delete System.Reflection.Emit.dll at following path:

C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\Xamarin.iOS\v1.0\Facades\System.Reflection.Emit.dll

like image 3
Subhan Ali Avatar answered Nov 13 '22 09:11

Subhan Ali