Xamarin.iOS 项目:CS1703:已导入多个具有等效标识的程序集 [英] Xamarin.iOS project: CS1703: Multiple assemblies with equivalent identity have been imported

查看:19
本文介绍了Xamarin.iOS 项目:CS1703:已导入多个具有等效标识的程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 .NET Standard 2.0 的跨平台(iOS 和 Android)Xamarin 解决方案.该解决方案由 Visual Studio 2017 构建(我已经尝试了当前版本和预览版本).Forms 和 Android 项目构建良好.但是,iOS 构建失败,出现以下错误:

1>CSC:错误 CS1703:已导入多个具有等效标识的程序集:'C:Users ewuser.nugetpackagessystem.reflection.emit4.3.0 ef etstandard1.1System.Reflection.Emit.dll' 和 'C:Program Files (x86)Microsoft Visual StudioPreviewEnterpriseCommon7IDEReferenceAssembliesMicrosoftFrameworkXamarin.iOSv1.0FacadesSystem.Reflection.Emit.dll'.删除重复引用之一.

我尝试了许多变通方法,如下所述:

在我看来,问题(正如错误所说)是 Visual Studio 安装了旧版本的 System.Reflection.Emit.但是,我找不到忽略它并使用 System.Reflection.Emit 版本的方法.正如我上面所说,我曾尝试在 Xamarin.iOS 项目中使用 project.json 文件,并手动忽略,但这不起作用.

其他人有什么想法吗?

顺便说一句,我注意到这个错误仍然对 Xamarin 开放.

Xamarin 错误

解决方案

感谢 @DirkWilhem 在 Xamarin 论坛网站上的回答,设法解决了这个问题.

基本上,将此添加到您的 Xamarin iOS 项目的 .csproj 文件中,以及其他 PackageReference 节点:

<版本>4.3.0</版本><ExcludeAssets>all</ExcludeAssets></PackageReference>

当然需要先确定nuget包已经添加到iOS包中.

Xamarin 论坛讨论

I've got a cross platform (iOS and Android) Xamarin solution using .NET Standard 2.0. The solution is being built by Visual Studio 2017 (I've tried both the current and preview versions). The Forms and Android projects build fine. However, the iOS fails to build, with the following error:

1>CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:Users ewuser.nugetpackagessystem.reflection.emit4.3.0 ef etstandard1.1System.Reflection.Emit.dll' and 'C:Program Files (x86)Microsoft Visual StudioPreviewEnterpriseCommon7IDEReferenceAssembliesMicrosoftFrameworkXamarin.iOSv1.0FacadesSystem.Reflection.Emit.dll'. Remove one of the duplicate references.

I've tried many work arounds as described here:

oren.codes

www.hanselman.com

github.com/NuGet

Unfortunately none of these suggestions work. I have also tried to add the System.Reflection.Emit nuget package directly to the Forms and/or to the iOS projects directly. This doesn't work either. Note that originally, the The System.Reflection.Emit package wasn't referenced directly by anything in the solution. It is being pulled in by the following nuget packages which are being explicitly referenced:

  • Acr.DeviceInfo (5.0.5)
  • akavache (6.0.0-alpha0038)
  • AutoMapper (6.2.2)
  • Microsoft.Identity.Client (1.1.1-preview0040)
  • Newtonsoft.Json (10.0.3)

Finally, I have tried the update-package -reinstall command in the package console to reinstall all packages for the iOS project. This doesn't work either.

-- update

Just to make this clear, neither the Xamarin Forms or the Xamarin iOS project directly reference System.Reflection.Emit. That package is being pulled in as a dependency of other nuget packages, just from packages that are installed into the Xamarin Forms project. I have confirmed all of the dependencies that are referenced by Nuget, are using the same version. See these screenshots:

It seems to me that the problem (as the error says) is that there is an old version of System.Reflection.Emit that was installed by Visual Studio. However, I can't find a way of ignoring it and using the version of System.Reflection.Emit instead. As I've said above, I have tried to use a project.json file in the Xamarin.iOS project, and manually ignoring, but this doesn't work.

Does anyone else have any ideas?

As an aside, I notice that this bug is still open for Xamarin.

Xamarin Bugs

解决方案

Managed to get this resolved thanks to an answer by @DirkWilhem on Xamarin Forums site.

Basically, add this to your Xamarin iOS project's .csproj file, with the other PackageReference nodes:

<PackageReference Include="System.Reflection.Emit">
  <Version>4.3.0</Version>
  <ExcludeAssets>all</ExcludeAssets>
</PackageReference>

Of course you need to make sure the nuget package has been added to the iOS package first.

Xamarin Forums discussion

这篇关于Xamarin.iOS 项目:CS1703:已导入多个具有等效标识的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆