【问题标题】:Xamarin Android will not compile: Multiple assemblies with equivalent identity have been importedXamarin Android 将无法编译:已导入具有相同标识的多个程序集
【发布时间】:2025-12-25 01:00:07
【问题描述】:

您可以在下面看到错误。

System.Runtime.InteropServices.WindowsRuntime

我的项目包中安装了一个版本,而 Mono 框架需要另一个版本。我觉得 Mono 框架应该是赢家。我的 iOS 版本不会发生此错误。

我将如何告诉 Visual Studio 社区 (Mac) 不要引用有问题的 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)

【问题讨论】:

  • System.Runtime.InteropServices.WindowsRuntime 4.0.1 升级到 4.3.0 可以消除此构建错误。以后如何避免这种行为?

标签: xamarin xamarin.android


【解决方案1】:

这周才遇到这个问题。不知道是什么变化引起的。

对我有用的是在 .csproj 参考中注释掉 HintPath:

<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>

重复问题here,顺便说一句。

【讨论】:

    最近更新 更多