来自 Automapper 的交叉帖子https://github.com/AutoMapper/AutoMapper/issues/2455
添加 AutoMapper >= 6.2.0 时,窗体 iOS 项目无法构建并输出 CS1703 错误。
确切的错误是
Error CS1703
Multiple assemblies with equivalent identity have been imported:
'C:\Users\plebm\.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.
这似乎是由于 AutoMapper 在 6.2.0 中添加了System.Runtime.Serialization.Primitives.4.3.0
的附加依赖项引起的
使用 VS 15.5.1
构建成功
构建失败
似乎自动映射器正在使用需要 Reflection.Emit 的东西。 这在 iOS 中是行不通的。
@jassmith感谢您的评论。 但是有一个问题,Reflection.Emit 会导致运行时错误或构建错误吗?
AutoMapper 使用表达式树编译,所以最终是 Expression.Lambda(...).Compile()。 我们将 Reflection.Emit 用于几个非常有针对性的场景。
基本上,我们要以 iOS 为目标,我们需要确保我们有一个根本不使用/引用 Reflection.Emit 的目标?
编译错误听起来像是最近 15.5 和绑定重定向的问题。
我有同样的问题。 我的解决方案是在我的 ios 项目中使用 project.json,如下所示:
{
"dependencies": {
"System.Reflection.Emit": {
"version": "4.3.0",
"exclude": "all"
}
},
"frameworks": {
"Xamarin.iOS,Version=v1.0": {}
},
"runtimes": {
"win": {}
}
}
@gmwilhelm我不知道 project.json 仍然是一个东西。 今天我学习
@jassmith您有机会再次查看这张票吗? 我知道您已将其标记为无效,但我认为这实际上是 Xam.Forms 应该解决的问题
我试图用一个空白的 NuGet 包在本地重现这个
引用 Reflection.Emit 但不使用它。 我得到了编译错误
有一次,但后来它神秘地消失了。
2018 年 1 月 2 日星期二下午 5:54 Wade Baglin [email protected]写道:
@jassmith https://github.com/jassmith有机会你会查看这个
又买票了? 我知道您已将其标记为无效,但我认为这实际上是
Xam.Forms 应该解决的问题—
您收到此消息是因为您发表了评论。
直接回复此邮件,在 GitHub 上查看
https://github.com/xamarin/Xamarin.Forms/issues/1380#issuecomment-354906852 ,
或使线程静音
https://github.com/notifications/unsubscribe-auth/AAGYMoqgqceTH4BPe4vqZwLkAoYb1YO0ks5tGsGxgaJpZM4Q-gOM
.
@pleb @jbogard
我能够在 Visual Studio 15.5.5 中重现 Multiple Assemblies 错误,但在 VSMac 中无法重现。 我创建了一个DevCom 项目来跟踪它。
仅供参考:为了使上述解决方法起作用,您可能需要重新启动 VS。 VS for Mac 发生在我身上。
@SvenEV在他的提交中有解决方案
将此添加到 csproj 文件中。 如果您使用 PackageReferences
<PackageReference Include="System.Reflection.Emit" Version="4.3.0">
<ExcludeAssets>all</ExcludeAssets>
</PackageReference>
我在这里写它是为了让它更明显,据我所见,发射接口在 Automapper 中用于映射例如到接口。
最有用的评论
@SvenEV在他的提交中有解决方案
将此添加到 csproj 文件中。 如果您使用 PackageReferences
我在这里写它是为了让它更明显,据我所见,发射接口在 Automapper 中用于映射例如到接口。