我刚刚通过 nuGet 在一个新项目上安装了 AutoMapper,但是当我运行代码时,出现以下错误:
Could not load file or assembly 'AutoMapper, Version=2.2.1.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
为什么它在寻找 Version=2.2.1.0,我该怎么办?恢复到那个版本?
最佳答案
您可能只想为 AutoMapper 添加绑定(bind)重定向,因为您的引用之一正在寻找 2.2 版
这应该这样做:
<dependentAssembly>
<assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
</dependentAssembly>
关于.net - 为什么 AutoMapper v3 不能工作,因为它正在寻找 v2.2.1.0?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18552159/