Xamarin Android will not compile: Multiple assembl

2019-08-25 00:04发布

问题:

You can see the error below.

System.Runtime.InteropServices.WindowsRuntime

One version is installed in my project's packages, and another one is needed for the Mono framework. I feel like the Mono Framework should probably be the one that wins. This error does not happen on my iOS builds.

How would I go about telling Visual Studio Community (Mac) not to reference the offending dll?

/myproject/path/MyApp.Droid/CSC: 
Error CS1703: Multiple assemblies with equivalent identity have been imported: 
'/myproject/path/packages/System.Runtime.InteropServices.WindowsRuntime.4.0.1/lib/netstandard1.3/System.Runtime.InteropServices.WindowsRuntime.dll' and 
'/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Facades/System.Runtime.InteropServices.WindowsRuntime.dll'. 
Remove one of the duplicate references. (CS1703) (MyApp.Droid)

回答1:

Ran into this just this week. No idea what change caused it.

What worked for me was commenting out the HintPath in the .csproj Reference:

<Reference Include="System.Runtime.InteropServices.WindowsRuntime">
    <!--HintPath>..\..\packages\System.Runtime.InteropServices.WindowsRuntime.4.0.1\lib\netstandard1.3\System.Runtime.InteropServices.WindowsRuntime.dll</HintPath-->
    <Private>True</Private>
</Reference>

Duplicate question here, btw.