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
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With